Converting between RTF to HTML and HTML to RTF

A while back I posted Converting RTF to HTML which showed how to convert RTF text into HTML markup using the WPF RichTextBox control.  Since then I have noticed many posts on forums asking for a free and easy way … Continue reading →


FastSharp 2.0

I just released a new version of my FastSharp program. Download it  or  View the source code This release contains some notable enhancements: Support for multiple languages C# Visual Basic F# Persistence of your current code language and snippet. This allows you to close FastSharp and start right back up from where you left off…


Useful Moq Extension Method

I have been working with ASP .NET MVC and I use the Moq mocking library to help test the code I write.   Often in ASP MVC anonymous objects are passed around as function arguments.  This is especially common in calls to RouteUrl.  Since I want to be able to test this and verify that it…


Converting RTF to HTML

Have you ever had the desire to convert some RTF text into HTML? Probably not. But if you do, then you are in luck! I recently had the need to do this conversion and after some searching found out a way to do it by enhancing a sample distributed in the MSDN library.  The sample…


I finally got fed up with Enum.Parse

I don’t know why I didn’t do this long ago, but I am done writing this: var val = (SomeEnum)Enum.Parse(typeof(SomeEnum),”someString”); I have typed this too many times and it annoys me.  I wrote a small extension method on the string type to make this better: public static class StringExtensions { public static T ToEnum<T>(this string…


My Visual Studio Code Snippets

The xUnit .Net codeplex page lists one useful Visual Studio code snippet for creating a Fact.  As you can tell I am fairly fond of code snippets so I created a few more which I use when writing facts. These are one line snippets that I find very convenient when writing my assertions. Below…


Inline Regular Expression Options

I was using attributes from the System.ComponentModel.DataAnnotations   namespace for model validation.  This namespace includes a few very useful validation attributes such as Required Attribute – Validates the field has a value Range Attribute – Validates the field is within a given range RegularExpression Attribute – Validates the field matches a given regular expression.   The…


Model Binder

When working with a multi-tier application I often find myself converting from one of the tiers object models to my own similar (but often different) model.  I often write code that would set one by one each property from a web tier object to my object.  In order to make this easier I wrote this…


SQL CE 3.5 with LINQ to SQL Revisited

A few days ago I made a post about using SQL CE 3.5 with LINQ to SQL.   I described a way to use connection pooling with SQL CE. A gracious blog reader (Mike Brown)  pointed out a way I could make my solution much simpler by using the [ThreadStatic] attribute.  I never heard of this…


SQL CE 3.5 with LINQ to SQL

Using LINQ to SQL with SQL CE 3.5 can be a bit of a challenge.  First off, the LINQ to SQL Visual Studio designer doesn’t support SQL CE so you need to run sqlmetal from the command line to create the object model (or write it by hand).  Once you get past this point then…