Update to DI Container initialization

Since I wrote the earlier code in "Using LINQ to initialize DI Containers" I've cleaned up the LINQ query to incorporate the assemblies loop and also to use the First extension method to make things a bit more readable.

Using LINQ to initialize DI Containers

Recently there have been some discussion on how to help initialize dependency injection containers. Ayende call this "Setting up Zero Fiction Projects" and uses the Boo language to create a DSL (Domain Specific Language) to specify components to be registered into the container. From hammet comes news around a fluent interface for adding components to Castle Windsor. The essence of both is to find all types in a given assembly that either implement a certain a certain interface or are a subclass of a layer supertype (I tend to have a ServiceBase that contains things Log and so on). We can use LINQ to achieve something similar to both the above approaches.

Using LINQ expressions to name Validation Rules

 In various places in code we want to use property names in our code, for instance validation or business rules are quick commonly named after the property they're validating. Usually you end up with code looking a little like this.

Creating an NHibernate Item Template

Visual Studio has some excellent facilities to create simple item and project templates, usually just create the class or project you want and select Export Template from the File Menu. However sometimes we want to do just a bit more than that. For instance when creating an NHibernate mapped class class we typically create the *.cs file and a related *.hbm.xml file, all the things we'd like to automate can't be handled by the Export Template wizard so we'll have to do a bit more work. These are automatically inserting the assembly attribute into the .hbm.xml, setting the build action to "Embedded Resource" and the custom tool to "NHibernateQueryGenerator".

Site Setup

I'm currently going through migrating the site from being a Google blog to a fully hosted site with CMS etc. There have been some highs and lows in this and I'll go through them all later just it case anyone else gets the same problems.