Thursday, September 3, 2009

Windows 7 Doesn't Include a Disk Image Mounter: Why?

This is a rant.

Why does Microsoft fail to include the ability to mount disk images as a basic feature of their operating systems?

I just don't get it.

Wednesday, September 2, 2009

StructureMap In Five Minutes or Less

[Filed under old stuff.]
StuctureMap is possibly the best IoC solution out there. And it is really easy to get started.

Here's some of the steps required to get started with something simple. These steps assume that you are going to handle configuration within an app.config or web.config file.
1. Go to http://sourceforge.net/projects/structuremap/files/ to get the latest release.
2. Copy the StructureMap.dll file to a location relative to your solution.
3. Add a reference to the StructureMap.dll to your project.
4. Within your config file, add the following configSection configuration:

<section name="StructureMap" type="StructureMap.Configuration.StructureMapConfigurationSection,StructureMap"/>

5. Within your config file, add the following configuration for StructureMap:

<StructureMap>
<DefaultInstance PluginType="Namespace.IInterfaceType,AssemblyNameForInterfaces" PluggedType="Namespace.ImplementationType,AssemblyNameForImplementation">
</DefaultInstance>
</StructureMap>

6. Add the following code to your project (this must be executed first):

ObjectFactory.Initialize(x =>
{
// Tell StructureMap to look for configuration
// from the App.config file
// The default is false
x.PullConfigurationFromAppConfig = true;
});

7. Use this code to get intstances of your mapped types, and you're ready to go:

ObjectFactory.GetInstance(typeof(Namespace.IInterfaceType));

There you have it. StructureMap in five minutes or less.