"Done is better than perfect."

Conway’s Law: how people relations reflects in sofware.

While surfing I discovered the Conway’s law. It basically says that, in software design, people tend to design software that reflects their organization. And this is very true. From Wikipedia:  “Another example: Consider a two-person team of software engineers, A and B. Say A designs and codes a software class X. Later, the team discovers […]

NUnit factories

I was getting mad to find out how to use factories on NUnit. I’ve been using factory methods with MBunit and they’re definetly helpful when you need to execute a test using several imputs. What was confusing me is the NUnit documentation: I’ve googled something like “NUnit factory” and the first results were pointing me […]

Split string without breaking words

Let say we got a long string that need to be splitted in a series of rows (of a certain lenght) . If the length exceed, we need to go wrap the text on a new line ensuring words are not broken. The solution is quite simple after all, before going to the new line […]

Create an image from text (Updated)

I’ve done a few changes and some additions on the code of the previous post. The CreateTextImage now prints the text at the center of the image, this is done using the Alignment property of the StringFormat class: public Bitmap CreateTextImage(string imageText) { Bitmap outputImage = new Bitmap(1, 1); int imageWidth, imageHeight = 0; //setup […]

Create an image from text, readwrite it as base64string.

public class ImageGenerator { /// <summary> /// credits to : http://chiragrdarji.wordpress.com/2008/05/09/generate-image-from-text-using-c-or-convert-text-in-to-image-using-c/ /// </summary> /// <param name=”imageText”>text to render</param> /// <returns>generated imaeg</returns> public Bitmap CreateTextImage(string imageText) { Bitmap outputImage = new Bitmap(1, 1); int imageWidth, imageHeight = 0; //setup the font Font imageFont = new Font(“Arial”, 20, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); //using graphic to mesure text and create […]

Generate an AppSettings wrapper using T4 templates.

The “Text Template Transformation Toolkit“, more friendly T4,  it is a code generation tool bundled in Visual Studio since the 2008, so if you are using VS2010 as I am doing there’s no need to look around, is already there. In a nutshell, the T4 allow to generate one or more files using a source […]

C# 4.0 Parallel features performance comparison

In order to exploit the power of multicore processor, the fourth version of the framework ships the Parallel features, easiest alternatives for multithreaded operations execution. With my (old) ASUS PRO60E, a Core 2 Duo T8100 2.1 GHz with 4GB of ram and Win7 x64, I made some tests to find out the performance differences between […]

Publish Rss feed using the Syndication namespace

Here’s an easy way to expose feeds using the new System.ServiceModel.Syndication namespace. Instead of dealing with XmlDocument the Rss20FeedFormatter class will be responsible to format the correct xml content for our feed. 1: SyndicationFeed feed = GetSyndicationFeed(); 2: Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(feed); 3: using (XmlWriter writer = XmlWriter.Create(context.Response.OutputStream)) 4: { 5: rssFormatter.WriteTo(writer); 6: writer.Flush(); […]

Error 29506 during installation of Management Studio Express

On Win7/Vista the UAC prevent the installation of the Management Studio Express fails. I just saw the MSI fails on my pc. To avoid it just run the msi with elevate privileges from the command prompt. For more details follow the link.

Ordinal suffixes with a custom IFormatProvider

Ordinal suffixes for english dates are composed by a number and 2 characters. Some classes of the framework provide an usueful implementation of the IFormatter provider, like the Datetime class which allow the developer to display the date in various ways, even with ordinal suffixes. If we  need to display the value of an object […]