It’s in Your Blood

December 30, 2007

This weekend I wrote a simple helper application that is supposed to divide a file with several SQL-scripts to several files. Nothing serious, but the work gave me two insights. The first one is, that it always, always, takes me half a day to re-learn the Regular Expression syntax. No matter how many times I used them, the next I'll need them I will still stare at the MSDN examples trying to figure out what's going on here. These magical strings are so goddamn incomprehensible. The second one, and the subject of this post is, that I don't...
no comments

Using ASP.NET MVC on IIS 5

December 15, 2007

This is a small note for people trying to play with the MVC framework, and that are currently using Windows XP. If you dislike the ASP.NET development server that comes by default with Visual Studio as much as I do, you've switched your MVC application to work against IIS already. WinXP is running IIS 5, and you'll notice that the routing will stop working for you once you make that switch. For instance, a request for /Products/Categories, where Products is a controller and Categories is an action on the controller, will fail. The problem is that IIS never...
tags: ,

String-less ArgumentNullException

December 9, 2007

The post I wrote yesterday about Expression Trees, and Jafar Husain's work, have inspired me to find some more cool usages for this feature. Consider this code: public class PersonRepository { public void Add(Person person, Context context) { if (person == null) throw new ArgumentNullException("person"); ...
tags: ,

C# 3.0 New Feature for the Week #5: Lambdas and Expression Trees

December 8, 2007

This week I'll talk about what seems to me like the coolest features of C# 3.0: lambda expressions and expression trees. Lambda Expressions We'll start with the part that is easier to understand. Remember anonymous methods from C# 2.0? Useful little bastards they are, only sometimes not so pleasant on the eyes. public void SortListIgnoreCase() { List<string> list = new List<string>{"abc", "ADE", "dol"}; list.Sort(delegate(string s1, string s2) ...
tags: ,
no comments

C# 3.0 New Feature for the Week #4: Extension Methods (and a PowerCollections Bonus!)

December 1, 2007

Consider the following. You need to sort an IEnumerable<T>. By default, Sort is only available for T (arrays) and List<T> (generic list). So you write something like this (probably not the most efficient implementation, this is just an example): namespace Utils { public static class CollectionUtils { public static IEnumerable<T> Sort<T>(IEnumerable<T> collection) { List<T> toSort = new List<T>(collection); ...
no comments