<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>.net and other musings &#187; Architecture</title>
	<atom:link href="http://benl.wordpress.com/category/architecture/feed/" rel="self" type="application/rss+xml" />
	<link>http://benl.wordpress.com</link>
	<description>Ben Lovell, an agile developer living in the UK.</description>
	<lastBuildDate>Thu, 16 Jul 2009 09:43:48 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='benl.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/43c6fe283d98c1764e951cd6dfface61?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>.net and other musings &#187; Architecture</title>
		<link>http://benl.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://benl.wordpress.com/osd.xml" title=".net and other musings" />
		<item>
		<title>ASP.NET Development Landscape</title>
		<link>http://benl.wordpress.com/2007/10/11/aspnet-development-landscape/</link>
		<comments>http://benl.wordpress.com/2007/10/11/aspnet-development-landscape/#comments</comments>
		<pubDate>Thu, 11 Oct 2007 22:33:49 +0000</pubDate>
		<dc:creator>benl</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ALT.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Castle]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Monorail]]></category>

		<guid isPermaLink="false">http://benl.wordpress.com/2007/10/11/aspnet-development-landscape/</guid>
		<description><![CDATA[With all the System.Web.Mvc goodness flying around at the moment, the Microsoft or nothing shops (you know, the ones that flat-out can&#8217;t adopt a technology unless it comes from the borg) might finally get a taste of how web development should be done. Unfortunately for the aforementioned reason, Monorail has never be an option for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benl.wordpress.com&blog=178045&post=131&subd=benl&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>With all the System.Web.Mvc goodness flying around at the moment, the Microsoft or nothing shops (you know, the ones that flat-out can&#8217;t adopt a technology unless it comes from the borg) might finally get a taste of how web development should be done. Unfortunately for the aforementioned reason, Monorail has never be an option for those developers.</p>
<p>The one thing that really excites me about MSMVC is the periphery of concepts that will be introduced by way of association: deep testability, SRP, DIP and SoC. Traditionally these practices aren&#8217;t promoted (or I might go so far as say <em>easily achieved</em>) heavily in the .NET technologies and frameworks coming out of Microsoft. As we&#8217;re focusing on ASP.NET at the moment, sure, they&#8217;re possible to adhere to whether you&#8217;re using ASP.NET in the presentation layer or not, but ASP.NET doesn&#8217;t <strong>promote</strong> them the same way the MVC framework will.</p>
<p>I can&#8217;t help but wonder how different the landscape might be now if MSMVC was released with .NET 1.0 instead of webforms?</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/benl.wordpress.com/131/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/benl.wordpress.com/131/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/benl.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/benl.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/benl.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/benl.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/benl.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/benl.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/benl.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/benl.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/benl.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/benl.wordpress.com/131/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benl.wordpress.com&blog=178045&post=131&subd=benl&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://benl.wordpress.com/2007/10/11/aspnet-development-landscape/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/146e52d49d361f85c0945487452fc6a0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ben</media:title>
		</media:content>
	</item>
		<item>
		<title>Dependency injection with Monorail and Windsor</title>
		<link>http://benl.wordpress.com/2007/06/27/dependency-injection-with-monorail-and-windsor/</link>
		<comments>http://benl.wordpress.com/2007/06/27/dependency-injection-with-monorail-and-windsor/#comments</comments>
		<pubDate>Wed, 27 Jun 2007 16:06:50 +0000</pubDate>
		<dc:creator>benl</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Castle]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Windsor]]></category>
		<category><![CDATA[mono-rail]]></category>

		<guid isPermaLink="false">http://benl.wordpress.com/2007/06/27/dependency-injection-with-monorail-and-windsor/</guid>
		<description><![CDATA[Dependency Injection (or IoC) is a&#160;practice I apply when designing software. It enables enforcement of the Single Responsibility Principle&#160;and also has the added&#160;side effect of producing more testable code.
Scott Bellware has posted an excellent write-up on dependency patterns and it got me thinking about my favoured approach with dependency injection and&#160;how the&#160;Castle Windsor container provides [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benl.wordpress.com&blog=178045&post=100&subd=benl&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://www.martinfowler.com/articles/injection.html" target="_blank">Dependency Injection (or IoC)</a> is a&nbsp;practice I apply when designing software. It enables enforcement of the Single Responsibility Principle&nbsp;and also has the added&nbsp;side effect of producing more testable code.</p>
<p><a href="http://codebetter.com/blogs/scott.bellware/default.aspx" target="_blank">Scott Bellware</a> has posted an excellent <a href="http://codebetter.com/blogs/scott.bellware/archive/2007/06/26/164729.aspx" target="_blank">write-up on dependency patterns</a> and it got me thinking about my favoured approach with dependency injection and&nbsp;how the&nbsp;<a href="http://castleproject.org/container/index.html" target="_blank">Castle Windsor</a> container provides that&nbsp;for us. I favour constructor based DI as it enforces the fact that your class <strong>must </strong>be wired up during initialisation. It makes your dependencies highly visible and as Scott mentions &#8211; goes some way to producing a self-documenting API. </p>
<p>Some of the common&nbsp;alternatives, or&nbsp;perhaps complimentary&nbsp;approaches include resolving dependencies from the container or service locator&nbsp;hidden in the constructor (dirty), or the provision of property setters for your dependent interfaces. Of course providing getters (or at least public getters) is a no-no as you would be exposing your dependencies to consumers thus violating encapsulation. But I guess this goes without saying?</p>
<p>Thankfully, <a href="http://castleproject.org/monorail/index.html" target="_blank">Monorail</a> controllers and their dependencies&nbsp;can be wired up using constructor based DI&nbsp;via <a href="http://wiki.castleproject.org/index.php/MonoRail:How_to:_Enable_Windsor_integration" target="_blank">RailsFacility</a> and Windsor integration. Take the following example:</p>
<p><a href="http://benl.files.wordpress.com/2007/06/dependencies.png"><img style="border-width:0;" height="172" alt="dependencies" src="http://benl.files.wordpress.com/2007/06/dependencies-thumb.png?w=240&#038;h=172" width="240" border="0"></a> </p>
<p><em>ContactController </em>in the diagram above is a simple&nbsp;Monorail controller that&nbsp;depends on the <em>IContactService </em>to carry out most of&nbsp;its work. Stemming from there the IContactService implementation has dependencies on <em>IContactRepository </em>and an external library (from <a href="http://www.google.co.uk/url?sa=t&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fnspectre.sourceforge.net%2F&amp;ei=wIqCRpqfDI2w0wT_mcThDA&amp;usg=AFQjCNEuVcjMocxJu8j8uD9feySLVQYNKA&amp;sig2=IyZ7tbJb0MNNWW6pif8M-A" target="_blank">NSpectre</a>) interface <em>IValidatorFactory</em> which is created using the Windsor factory facility and some custom factory code, but more on that later&#8230; As you can see from the model, the dependencies are injected via constructor arguments.</p>
<p>Using the RailsFacility is fairly simple, rather than me explaining it I&#8217;ll point you to the <a href="http://wiki.castleproject.org/index.php/MonoRail:How_to:_Enable_Windsor_integration" target="_blank">docs here</a>. Once you&#8217;ve got the facility and container set up, you simple declare your controllers and their dependent components via configuration: </p>
<pre style="width:441px;height:126px;"><span style="color:rgb(0,0,255);">&lt;</span><span style="color:rgb(163,21,21);">component</span><span style="color:rgb(0,0,255);"> </span><span style="color:rgb(255,0,0);">id</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">contact.controller</span>"<span style="color:rgb(0,0,255);"> </span><span style="color:rgb(255,0,0);">type</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">Campaigns.Controllers.ContactController, Campaigns.Controllers</span>"<span style="color:rgb(0,0,255);">&gt;
      &lt;</span><span style="color:rgb(163,21,21);">parameters</span><span style="color:rgb(0,0,255);">&gt;
        &lt;</span><span style="color:rgb(163,21,21);">mailTo</span><span style="color:rgb(0,0,255);">&gt;</span>benjamin.lovell@gmail.com<span style="color:rgb(0,0,255);">&lt;/</span><span style="color:rgb(163,21,21);">mailTo</span><span style="color:rgb(0,0,255);">&gt;
        &lt;</span><span style="color:rgb(163,21,21);">subject</span><span style="color:rgb(0,0,255);">&gt;</span>Contact message from Website<span style="color:rgb(0,0,255);">&lt;/</span><span style="color:rgb(163,21,21);">subject</span><span style="color:rgb(0,0,255);">&gt;
      &lt;/</span><span style="color:rgb(163,21,21);">parameters</span><span style="color:rgb(0,0,255);">&gt;
    &lt;/</span><span style="color:rgb(163,21,21);">component</span><span style="color:rgb(0,0,255);">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>I&#8217;ve explicitly declared some of the required values for the <em>ContactController</em> constructor above. Just as reminder the signature for <em>ContactController</em> &nbsp;constructor:</p>
<pre style="width:441px;height:39px;"><span style="color:rgb(0,0,255);">public</span> ContactController(<span style="color:rgb(43,145,175);">IContactService</span> contactService, <span style="color:rgb(0,0,255);">string</span> mailTo, <span style="color:rgb(0,0,255);">string</span> subject)</pre>
<p>When the <em>ContactController&nbsp;</em>is wired up by windsor the&nbsp;<em>IContactService contactService&nbsp;</em>argument&nbsp;is resolved to the following service configured in my components.config file:</p>
<pre style="width:442px;height:93px;"><span style="color:rgb(0,0,255);">&lt;</span><span style="color:rgb(163,21,21);">component</span><span style="color:rgb(0,0,255);"> </span><span style="color:rgb(255,0,0);">id</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">contact-service</span>"
<span style="color:rgb(0,0,255);">               </span><span style="color:rgb(255,0,0);">service</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">Campaigns.Core.IContactService, Campaigns.Core</span>"
<span style="color:rgb(0,0,255);">               </span><span style="color:rgb(255,0,0);">type</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">Campaigns.Services.ContactService, Campaigns.Services</span>"<span style="color:rgb(0,0,255);">&gt;
    &lt;/</span><span style="color:rgb(163,21,21);">component</span><span style="color:rgb(0,0,255);">&gt;</span></pre>
<p>Of course, <em>ContactService </em>also joins in the fun and has its dependencies injected via the same means:</p>
<pre style="width:440px;height:83px;"><span style="color:rgb(0,0,255);">&lt;</span><span style="color:rgb(163,21,21);">component</span><span style="color:rgb(0,0,255);"> </span><span style="color:rgb(255,0,0);">id</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">contact-repository</span>"
<span style="color:rgb(0,0,255);">               </span><span style="color:rgb(255,0,0);">service</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">Campaigns.Core.IContactRepository, Campaigns.Core</span>"
<span style="color:rgb(0,0,255);">               </span><span style="color:rgb(255,0,0);">type</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">Campaigns.Repository.ContactRepository, Campaigns.Repository</span>"<span style="color:rgb(0,0,255);"> /&gt;</span></pre>
<p>Windsor detects that the <em>ContactService </em>constructor takes a <em>IContactRepository </em>argument and resolves this automatically. </p>
<p>Now for the keen-eyed among you, and going back to my point earlier regarding the <em>IValidatorFactory </em>dependency&#8230; This is resolved using the natty Windsor factory facility, the <a href="http://blog.bittercoder.com/PermaLink,guid,07925133-ae33-41dd-bc50-2b49a5434e19.aspx" target="_blank">best explanation of which is here</a>. In my configuration I state that <em>IValidatorFactory </em>dependencies should be resolved via my custom factory code: </p>
<pre style="width:447px;height:211px;"><span style="color:rgb(0,0,255);">using</span> NSpectre.Core;
<span style="color:rgb(0,0,255);">using</span> NSpectre.Core.Configuration;
<span style="color:rgb(0,0,255);">using</span> NSpectre.Core.Implementation;

<span style="color:rgb(0,0,255);">namespace</span> Campaigns.Core
{
    <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;summary&gt;
</span>    <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> Factory for NSpectre validators
</span>    <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;/summary&gt;
</span>    <span style="color:rgb(0,0,255);">public</span> <span style="color:rgb(0,0,255);">class</span> <span style="color:rgb(43,145,175);">NSpectreFactory</span> : <span style="color:rgb(43,145,175);">INSpectreFactory
</span>    {
<span style="color:rgb(0,0,255);">        #region</span> Fields

        <span style="color:rgb(0,0,255);">private</span> <span style="color:rgb(0,0,255);">readonly</span> <span style="color:rgb(0,0,255);">string</span> xmlEmbeddedResourcePath;
        <span style="color:rgb(0,0,255);">private</span> <span style="color:rgb(0,0,255);">readonly</span> <span style="color:rgb(0,0,255);">bool</span> saveGeneratedCode = <span style="color:rgb(0,0,255);">false</span>;
        <span style="color:rgb(0,0,255);">private</span> <span style="color:rgb(0,0,255);">readonly</span> <span style="color:rgb(0,0,255);">string</span> path;

<span style="color:rgb(0,0,255);">        #endregion

        #region</span> Constructors

        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;summary&gt;
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> Initialises the factory with the embedded resource path.
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;/summary&gt;
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;param name="xmlEmbeddedResourcePath"&gt;</span><span style="color:rgb(0,128,0);">The path to the embedded resource.</span><span style="color:rgb(128,128,128);">&lt;/param&gt;
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;param name="saveGeneratedCode"&gt;</span><span style="color:rgb(0,128,0);">Save the generated code</span><span style="color:rgb(128,128,128);">&lt;/param&gt;
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;param name="path"&gt;</span><span style="color:rgb(0,128,0);">The path to save the code to</span><span style="color:rgb(128,128,128);">&lt;/param&gt;
</span>        <span style="color:rgb(0,0,255);">public</span> NSpectreFactory(<span style="color:rgb(0,0,255);">string</span> xmlEmbeddedResourcePath, <span style="color:rgb(0,0,255);">bool</span> saveGeneratedCode, <span style="color:rgb(0,0,255);">string</span> path) : <span style="color:rgb(0,0,255);">this</span>(xmlEmbeddedResourcePath)
        {
            <span style="color:rgb(0,0,255);">this</span>.saveGeneratedCode = saveGeneratedCode;
            <span style="color:rgb(0,0,255);">this</span>.path = path;
        }

        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;summary&gt;
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> Initialises the factory with the path to the NSpectre configuration embedded resource.
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;/summary&gt;
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;param name="xmlEmbeddedResourcePath"&gt;&lt;/param&gt;
</span>        <span style="color:rgb(0,0,255);">public</span> NSpectreFactory(<span style="color:rgb(0,0,255);">string</span> xmlEmbeddedResourcePath)
        {
            <span style="color:rgb(0,0,255);">this</span>.xmlEmbeddedResourcePath = xmlEmbeddedResourcePath;
        }

<span style="color:rgb(0,0,255);">        #endregion

        #region</span> Properties

        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;summary&gt;
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> Gets the path to the configuration embedded resource.
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;/summary&gt;
</span>        <span style="color:rgb(0,0,255);">public</span> <span style="color:rgb(0,0,255);">string</span> XmlEmbeddedResourcePath
        {
            <span style="color:rgb(0,0,255);">get</span> { <span style="color:rgb(0,0,255);">return</span> xmlEmbeddedResourcePath; }
        }

        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;summary&gt;
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> Gets a flag indicating whether NSpectre should save the generated code.
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;/summary&gt;
</span>        <span style="color:rgb(0,0,255);">public</span> <span style="color:rgb(0,0,255);">bool</span> SaveGeneratedCode
        {
            <span style="color:rgb(0,0,255);">get</span> { <span style="color:rgb(0,0,255);">return</span> saveGeneratedCode; }
        }

        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;summary&gt;
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> Gets the path to save the generated code to.
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;/summary&gt;
</span>        <span style="color:rgb(0,0,255);">public</span> <span style="color:rgb(0,0,255);">string</span> Path
        {
            <span style="color:rgb(0,0,255);">get</span> { <span style="color:rgb(0,0,255);">return</span> path; }
        }

<span style="color:rgb(0,0,255);">        #endregion

        #region</span> Methods

        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;summary&gt;
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> Creates the validator factory
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;/summary&gt;
</span>        <span style="color:rgb(128,128,128);">///</span><span style="color:rgb(0,128,0);"> </span><span style="color:rgb(128,128,128);">&lt;returns&gt;</span><span style="color:rgb(0,128,0);">The validator factory, initialised</span><span style="color:rgb(128,128,128);">&lt;/returns&gt;
</span>        <span style="color:rgb(0,0,255);">public</span> <span style="color:rgb(43,145,175);">IValidatorFactory</span> CreateFactory()
        {
            <span style="color:rgb(43,145,175);">IConfigurationReader</span> reader = <span style="color:rgb(0,0,255);">new</span> <span style="color:rgb(43,145,175);">EmbbeddedXmlResourceConfigurationReader</span>(xmlEmbeddedResourcePath, <span style="color:rgb(0,0,255);">new</span> <span style="color:rgb(43,145,175);">NullLogger</span>());
            <span style="color:rgb(43,145,175);">Initialiser</span> initialiser = <span style="color:rgb(0,0,255);">new</span> <span style="color:rgb(43,145,175);">Initialiser</span>();

            <span style="color:rgb(0,0,255);">if</span> (SaveGeneratedCode)
                <span style="color:rgb(0,0,255);">return</span> initialiser.CreateValidatorFactory(reader, saveGeneratedCode, path);
            <span style="color:rgb(0,0,255);">else
</span>                <span style="color:rgb(0,0,255);">return</span> initialiser.CreateValidatorFactory(reader);
        }

<span style="color:rgb(0,0,255);">        #endregion
</span>    }
}</pre>
<p>The custom factory is hooked up using the following configuration:</p>
<pre style="width:447px;height:208px;"><span style="color:rgb(0,0,255);">&lt;</span><span style="color:rgb(163,21,21);">component</span><span style="color:rgb(0,0,255);"> </span><span style="color:rgb(255,0,0);">id</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">nspectre.factory</span>"<span style="color:rgb(0,0,255);">
               </span><span style="color:rgb(255,0,0);">service</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">Campaigns.Core.INSpectreFactory, Campaigns.Core</span>"<span style="color:rgb(0,0,255);">
               </span><span style="color:rgb(255,0,0);">type</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">Campaigns.Core.NSpectreFactory, Campaigns.Core</span>"<span style="color:rgb(0,0,255);">&gt;
      &lt;</span><span style="color:rgb(163,21,21);">parameters</span><span style="color:rgb(0,0,255);">&gt;
        &lt;</span><span style="color:rgb(163,21,21);">xmlEmbeddedResourcePath</span><span style="color:rgb(0,0,255);">&gt;</span>Campaigns.Core.Model.NSpectreValidations.xml, Campaigns.Core<span style="color:rgb(0,0,255);">&lt;/</span><span style="color:rgb(163,21,21);">xmlEmbeddedResourcePath</span><span style="color:rgb(0,0,255);">&gt;
      &lt;/</span><span style="color:rgb(163,21,21);">parameters</span><span style="color:rgb(0,0,255);">&gt;
    &lt;/</span><span style="color:rgb(163,21,21);">component</span><span style="color:rgb(0,0,255);">&gt;

    &lt;</span><span style="color:rgb(163,21,21);">component</span><span style="color:rgb(0,0,255);"> </span><span style="color:rgb(255,0,0);">id</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">nspectre.default</span>"<span style="color:rgb(0,0,255);">
               </span><span style="color:rgb(255,0,0);">type</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">NSpectre.Core.IValidatorFactory, NSpectre.Core</span>"
<span style="color:rgb(0,0,255);">               </span><span style="color:rgb(255,0,0);">factoryId</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">nspectre.factory</span>"
<span style="color:rgb(0,0,255);">               </span><span style="color:rgb(255,0,0);">factoryCreate</span><span style="color:rgb(0,0,255);">=</span>"<span style="color:rgb(0,0,255);">CreateFactory</span>"<span style="color:rgb(0,0,255);"> /&gt;</span></pre>
<p>You really notice the effectiveness of this approach when adding new controllers to your project. You simply add the controller code, define its dependencies in the constructor and add the configuration for the controller to your controllers.config file and everything is resolved and injected for you at runtime. Very nice indeed, I&#8217;m sure you will agree!</p>
<p>Testing is made easy by providing dynamic mocks. To make this an even nicer experience take a look at the <a href="http://blog.eleutian.com/CommentView,guid,762249da-e25a-4503-8f20-c6d59b1a69bc.aspx" target="_blank">AutoMockingContainer</a> from the nice folks at <a href="http://blog.eleutian.com/" target="_blank">Eleutian</a>!</p>
<p>To wrap up I have to say: Castle really does kick the llama&#8217;s ass. </p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/benl.wordpress.com/100/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/benl.wordpress.com/100/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/benl.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/benl.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/benl.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/benl.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/benl.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/benl.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/benl.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/benl.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/benl.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/benl.wordpress.com/100/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benl.wordpress.com&blog=178045&post=100&subd=benl&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://benl.wordpress.com/2007/06/27/dependency-injection-with-monorail-and-windsor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/146e52d49d361f85c0945487452fc6a0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ben</media:title>
		</media:content>

		<media:content url="http://benl.files.wordpress.com/2007/06/dependencies-thumb.png" medium="image">
			<media:title type="html">dependencies</media:title>
		</media:content>
	</item>
		<item>
		<title>BackgroundMotion sample application</title>
		<link>http://benl.wordpress.com/2007/06/20/backgroundmotion-sample-application/</link>
		<comments>http://benl.wordpress.com/2007/06/20/backgroundmotion-sample-application/#comments</comments>
		<pubDate>Wed, 20 Jun 2007 08:46:03 +0000</pubDate>
		<dc:creator>benl</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Architecture]]></category>

		<guid isPermaLink="false">http://benl.wordpress.com/2007/06/20/backgroundmotion-sample-application/</guid>
		<description><![CDATA[I found BackgroundMotion via Andrew Peter&#8217;s blog -&#160;created in partnership with Microsoft as a &#8220;best practice&#8221; example application. I&#8217;ve had a look at the source code and at first glance it&#8217;s quite a nicely architected solution&#8230; Certainly better than some of the&#160;starter kits&#160;coming out of Microsoft (anyone remember Petshop!?). Anyway it features all of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benl.wordpress.com&blog=178045&post=94&subd=benl&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I found <a href="http://www.backgroundmotion.com/Default.aspx" target="_blank">BackgroundMotion</a> via <a href="http://andrewpeters.net/2007/06/19/backgroundmotion-code-sample/" target="_blank">Andrew Peter&#8217;s</a> blog -&nbsp;created in partnership with Microsoft as a &#8220;best practice&#8221; example application. I&#8217;ve had a look at the source code and at first glance it&#8217;s quite a nicely architected solution&#8230; Certainly better than some of the&nbsp;starter kits&nbsp;coming out of Microsoft (anyone remember Petshop!?). Anyway it features all of the following:</p>
<blockquote><ul>
<li>Use of a domain-driven design techniques. Repository and Unit of Work abstractions over LINQ to SQL
<li>Model-level validation using the Validation Block
<li>Dependency injection using Composite Web Block
<li>Using Lucene.NET to index a domain model
<li>Using MVP with declarative data-binding in the presentation layer </li>
</ul>
</blockquote>
<p>Nice to see Lucene.NET being employed. As is NUnit. I&#8217;ll have a closer look when I get a chance. Expect some comments shortly.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/benl.wordpress.com/94/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/benl.wordpress.com/94/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/benl.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/benl.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/benl.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/benl.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/benl.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/benl.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/benl.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/benl.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/benl.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/benl.wordpress.com/94/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benl.wordpress.com&blog=178045&post=94&subd=benl&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://benl.wordpress.com/2007/06/20/backgroundmotion-sample-application/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/146e52d49d361f85c0945487452fc6a0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ben</media:title>
		</media:content>
	</item>
	</channel>
</rss>