Recursive File List Builder

This class builds a file list out of a directory tree, starting from a specified folder. Search pattern (like *.asp, *.exe) and the level (or depth 0=all, 1=current, n=n levels) of recursion to number of sub-directories can be specified. Usage of the class is given towards the end of the article.

and the usage would be like this…

Generate Table Schema

This is a simple (but often useful) tool to generate the xml schema of a database table. The tool supports only SQL Server over Windows Authentication. The source code here can be easily extended for other uses.

SELECT column values into a concatenated string (SQL)

Often there is a requirement to get column values in a table to a concatenated string. Say, we have e-mail ID as one column on a person table and want a comma separated list of all (or a subset) of e-mail ID’s.

Here is one dirty little piece of code to do just that! :)

The above query returns a concatenated string of values in EmailID column, separated by semi-colon.

Dependency Injection

This is one pattern many of us use without even realising we are using it. The premises are pretty simple.

Let’s say we are doing a sequential workflow, and that each step in the flow can be done by any among the various implementations of a particular interface. Now, we have two options – either write a controller class that loads the specific types and executes the flow (in which case we write one controller per flow) or have a configuration file that specifies the implementation at each step and the controller just go about invoking the interface. It is a no-brainer to see that the latter approach is more flexible.

In .Net, this is achieved by loading the assembly and type at runtime.

Here, IMashup is the interface and the assembly and type names are expected to come from a configuration file (or equivalent).