<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Free Tools</title>
        <link>http://geekswithblogs.net/Podwysocki/category/4470.aspx</link>
        <description>Free Tools</description>
        <language>en-US</language>
        <copyright>Matthew Podwysocki</copyright>
        <managingEditor>matthew.podwysocki@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Unity Community Contributions and Interception</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/04/11/121194.aspx</link>
            <description>Now that Unity has been released into the wild, there has definitely been a bit of interest swirling around it.  One of my key wants for a good IoC container is basic interception capabilities.  My criteria for evaluating a container usually comes down to the following:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;Configurability (XML, DSL, Code)&lt;/li&gt;
    &lt;li&gt;Dependency Resolution, usually opinionated&lt;/li&gt;
    &lt;li&gt;Lifetime Management (Per Thread, Pooled, Singleton, Transient, etc)&lt;/li&gt;
    &lt;li&gt;Extensibility for Interception&lt;/li&gt;
&lt;/ul&gt;
So, I realized that Unity was missing some of these things in the first go around.  Since Unity was built on top of ObjectBuilder2, a next generation version of the often maligned ObjectBuilder which also included some sample DI containers and a flexible interception model.  Today's post will cover that and a bit more.  I realize that I still am working on a post of AOP in the Enterprise and Spring.NET which is coming soon.&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;
&lt;br /&gt;
Where We Are&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
But, before we begin today, let's see what we've already covered in the past:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/04/07/unity-1-0-released-into-the-wild.aspx"&gt;Unity 1.0 Released into the Wild&lt;/a&gt;&lt;br /&gt;
    Unity 1.0 released and available on MSDN.  Unfortunately, registration is required...&lt;br /&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/03/27/ioc-and-unity-configuration-changes-for-the-better.aspx"&gt;IoC and Unity - Configuration Changes for the Better&lt;/a&gt;&lt;br /&gt;
    Covers the configuration changes to allow for better parameterization for constructors&lt;br /&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/03/25/ioc-and-unity-the-basics-and-interception.aspx"&gt;IoC and Unity - The Basics and Interception&lt;/a&gt;&lt;br /&gt;
    Talking about the basics of IoC containers and the interception models&lt;br /&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/03/07/ioc-container-unity-and-breaking-changes-galore.aspx"&gt;IoC Container, Unity and Breaking Changes Galore&lt;/a&gt;&lt;br /&gt;
    Covers the breaking changes made from the old Unity drop to the new one&lt;br /&gt;
    &lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/03/04/ioc-containers-unity-and-objectbuilder2-the-saga-continues.aspx"&gt;&lt;br /&gt;
    &lt;/a&gt;     &lt;/li&gt;
    &lt;li&gt;&lt;a href="javascript:void(0);/*1206509408817*/"&gt;IoC Containers, Unity and ObjectBuilder2 - The Saga Continues&lt;/a&gt;&lt;br /&gt;
    Managing instances and parameter mapping resolution&lt;br /&gt;
    &lt;a href="http://geekswithblogs.net/Podwysocki/archive/2008/02/26/120002.aspx"&gt;&lt;br /&gt;
    &lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/02/26/ioc-and-the-unity-application-block-once-again.aspx"&gt;IoC and the Unity Application Block Once Again&lt;/a&gt;&lt;br /&gt;
    Setter Injection versus Constructor Injection and PostSharp4Unity&lt;br /&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/02/22/ioc-and-the-unity-application-block-going-deeper.aspx"&gt;IoC and the Unity Application Block - Going Deeper&lt;/a&gt;&lt;br /&gt;
    Constructor Injection and comparing Unity with Castle Windsor&lt;br /&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/02/18/ioc-and-the-unity-application-block.aspx"&gt;IoC and the Unity Application Block&lt;/a&gt;&lt;br /&gt;
    Covering ObjectBuilder and Unity Application Block&lt;/li&gt;
&lt;/ul&gt;
Now that we've look at the history of this series, let's go ahead and get started.&lt;br /&gt;
&lt;br style="font-weight: bold;" /&gt;
&lt;span style="font-weight: bold;"&gt;Unity Contributions&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Since Unity was released last Friday, there has been a community effort much like the ASP.NET MVC Contributions, &lt;a href="http://www.codeplex.com/MVCContrib"&gt;MVCContrib&lt;/a&gt;, called &lt;a href="http://www.codeplex.com/unitycontributions"&gt;Unity Community Contributions&lt;/a&gt;.  This project is intended to fill in the gaps where the community feels that Unity can be extended, much like most other IoC containers.  As I stated above, one of those crucial things that I thought was missing was taking the ObjectBuilder2 Interception model and applying it towards Unity.  I wasn't interested as much in the Policy Injection Application Block, although nice, is a bit heavyweight for the basic operations I would like.  Instead, the OB2 would suffice for most things that I'd want with a container.  So, that led me to another topic...&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;ObjectBuilder2 Interception == Unity Interception?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Since I was particularly motivated to see the OB2 Interception model pushed into Unity, I decided to give it a go myself.  For the most part, I was successful in a way, but I wasn't using the right extensibility model.  From that point, I got in contact with&lt;a href="http://blogs.msdn.com/scottdensmore/"&gt; Scott Densmore&lt;/a&gt;, a PM within the Patterns &amp;amp; Practices group and one of the authors of ObjectBuilder2 along with &lt;a href="http://bradwilson.typepad.com/"&gt;Brad Wilson&lt;/a&gt;.  From that point, he was able to take the original OB2 Interception model and fit it nicely into the Unity extensibility model.  The code is now available on the Unity Community Contributions and you can find those commits by Scott &lt;a href="http://www.codeplex.com/unitycontributions/SourceControl/ListDownloadableCommits.aspx"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
So, let's take a look at what it entails.  As I tell most people, you learn the most about the software with good unit, I mean behavioral tests where I can really grok the intent of the code much better than most documentation.  I encourage most people to do the same.  I'd rather stay away from those projects that don't have tests to back up their work.&lt;br /&gt;
&lt;br /&gt;
Like I said before, ObjectBuilder2 had several ways of intercepting calls.  There are several interception strategies worth mentioning:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;Virtual Method interception&lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Interface Method interception&lt;/li&gt;
    &lt;li&gt;.NET Remoting interception (MarshalByRefObject)&lt;/li&gt;
&lt;/ul&gt;
From that, you have two ways of registering your interest for interception:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;Intercept via code&lt;/li&gt;
    &lt;li&gt;Intercept via attributes&lt;/li&gt;
&lt;/ul&gt;
Now that we've laid down the basics, let's take a look at some of the unit tests.  You'll notice that &lt;a href="http://codeplex.com/xunit"&gt;xUnit.net&lt;/a&gt; was used for the unit tests.  Yes, I know, I've mentioned it a few times lately.  Anyhow, let's look first at virtual method interception.&lt;br /&gt;
&lt;br /&gt;
Before we get started on that, in order to perform interception, we need to implement the IInterceptionHandler interface.  For the unit tests, this will be used to record the various actions that happened during the interception process.  But you can imagine it to do any number of things such as logging, transaction management, security and so on.  Any of those cross cutting concerns, really.&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green128\blue0;\red40\green40\blue40;\red255\green255\blue255;\red255\green255\blue0;\red43\green145\blue175;}??\fs16 \cf1\cb2\highlight2 namespace\cf3  UnitySamples\par ??\{\par ??    \cf1 public\cf3  \cf1 static\cf3  \cf1 class\cf3  \cf4 IoC\par ??\cf3     \{\par ??        \cf1 private\cf3  \cf1 static\cf3  \cf5 IDependencyResolver\cf3  resolver;\par ??\par ??        \cf1 public\cf3  \cf1 static\cf3  \cf1 void\cf3  Initialize(\cf5 IDependencyResolver\cf3  resolver)\par ??        \{\par ??            \cf4 IoC\cf3 .resolver = resolver;\par ??        \}\par ??\par ??        \cf1 public\cf3  \cf1 static\cf3  T Resolve&amp;lt;T&amp;gt;()\par ??        \{\par ??            \cf1 return\cf3  resolver.Resolve&amp;lt;T&amp;gt;();\par ??        \}\par ??\par ??        \cf1 public\cf3  \cf1 static\cf3  T Resolve&amp;lt;T&amp;gt;(\cf1 string\cf3  name)\par ??        \{\par ??            \cf1 return\cf3  resolver.Resolve&amp;lt;T&amp;gt;(name);\par ??        \}\par ??    \}\par ??\}\par ??}
--&gt;&lt;br /&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(255, 153, 0);"&gt;public delegate&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IMethodReturn&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;InovkeHandlerDelegate&lt;/span&gt;&lt;span style="color: rgb(0, 204, 255);"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;IMethodInvocation&lt;/span&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;call,&lt;/span&gt;&lt;br /&gt;
                                                        &lt;span style="color: rgb(43, 145, 175);"&gt;GetNextHandlerDelegate&lt;/span&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;getNext);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
    &lt;span style="color: rgb(255, 153, 0);"&gt;public delegate&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;InovkeHandlerDelegate&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;GetNextHandlerDelegate&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;();&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
    &lt;span style="color: rgb(255, 153, 0);"&gt;public interface&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IInterceptionHandler&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(255, 255, 255);"&gt;     {&lt;/span&gt;&lt;br /&gt;
        &lt;span style="color: rgb(43, 145, 175);"&gt;IMethodReturn &lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;Invoke(&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;IMethodInvocation&lt;/span&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;call,&lt;/span&gt;&lt;br /&gt;
                             &lt;span style="color: rgb(43, 145, 175);"&gt;GetNextHandlerDelegate&lt;/span&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;getNext);&lt;/span&gt;&lt;br style="color: rgb(255, 255, 255);" /&gt;
&lt;span style="color: rgb(255, 255, 255);"&gt;     }&lt;/span&gt;&lt;br style="color: rgb(255, 255, 255);" /&gt;
&lt;span style="color: rgb(255, 255, 255);"&gt; } &lt;/span&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;   &lt;span style="color: rgb(255, 153, 0);"&gt;public class&lt;/span&gt; &lt;span style="color: rgb(255, 255, 0);"&gt;RecordingHandler &lt;/span&gt;: &lt;span style="color: rgb(43, 145, 175);"&gt;IInterceptionHandler&lt;/span&gt;&lt;br /&gt;
    {&lt;br /&gt;
        &lt;span style="color: rgb(255, 153, 0);"&gt;readonly string &lt;/span&gt;message;&lt;br /&gt;
&lt;br /&gt;
        [&lt;span style="color: rgb(255, 255, 0);"&gt;InjectionConstructor&lt;/span&gt;]&lt;br /&gt;
        &lt;span style="color: rgb(255, 153, 0);"&gt;public &lt;/span&gt;RecordingHandler()&lt;br /&gt;
        {&lt;br /&gt;
            message = &lt;span style="color: rgb(0, 255, 0);"&gt;""&lt;/span&gt;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        &lt;span style="color: rgb(255, 153, 0);"&gt;public &lt;/span&gt;RecordingHandler(&lt;span style="color: rgb(255, 153, 0);"&gt;string &lt;/span&gt;message)&lt;br /&gt;
        {&lt;br /&gt;
            &lt;span style="color: rgb(255, 153, 0);"&gt;this&lt;/span&gt;.message = &lt;span style="color: rgb(255, 153, 0);"&gt;string&lt;/span&gt;.Format(&lt;span style="color: rgb(0, 255, 0);"&gt;" ({0})"&lt;/span&gt;, message);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        &lt;span style="color: rgb(255, 153, 0);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;IMethodReturn&lt;/span&gt; Invoke(&lt;span style="color: rgb(43, 145, 175);"&gt;IMethodInvocation&lt;/span&gt; call,&lt;br /&gt;
                                    &lt;span style="color: rgb(43, 145, 175);"&gt;GetNextHandlerDelegate&lt;/span&gt; getNext)&lt;br /&gt;
        {&lt;br /&gt;
            &lt;span style="color: rgb(255, 255, 0);"&gt;Recorder&lt;/span&gt;.Records.Add(&lt;span style="color: rgb(0, 255, 0);"&gt;"Before Method"&lt;/span&gt; + message);&lt;br /&gt;
            &lt;span style="color: rgb(43, 145, 175);"&gt;IMethodReturn &lt;/span&gt;result = getNext().Invoke(call, getNext);&lt;br /&gt;
            &lt;span style="color: rgb(255, 255, 0);"&gt;Recorder&lt;/span&gt;.Records.Add(&lt;span style="color: rgb(0, 255, 0);"&gt;"After Method" &lt;/span&gt;+ message);&lt;br /&gt;
            &lt;span style="color: rgb(255, 153, 0);"&gt;return &lt;/span&gt;result;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
We have the ability through the Invoke method to do things before the method as well as after.  Should we need to modify values before the method is called, we can go ahead and do so.  Now that we looked at that, let's get to some unit tests.  First off, let's look at interception through just code.  I like this approach as opposed to attributes due to not cluttering the domain model and making it more configurable at run time.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green128\blue0;\red40\green40\blue40;\red255\green255\blue255;\red255\green255\blue0;\red43\green145\blue175;}??\fs16 \cf1\cb2\highlight2 namespace\cf3  UnitySamples\par ??\{\par ??    \cf1 public\cf3  \cf1 static\cf3  \cf1 class\cf3  \cf4 IoC\par ??\cf3     \{\par ??        \cf1 private\cf3  \cf1 static\cf3  \cf5 IDependencyResolver\cf3  resolver;\par ??\par ??        \cf1 public\cf3  \cf1 static\cf3  \cf1 void\cf3  Initialize(\cf5 IDependencyResolver\cf3  resolver)\par ??        \{\par ??            \cf4 IoC\cf3 .resolver = resolver;\par ??        \}\par ??\par ??        \cf1 public\cf3  \cf1 static\cf3  T Resolve&amp;lt;T&amp;gt;()\par ??        \{\par ??            \cf1 return\cf3  resolver.Resolve&amp;lt;T&amp;gt;();\par ??        \}\par ??\par ??        \cf1 public\cf3  \cf1 static\cf3  T Resolve&amp;lt;T&amp;gt;(\cf1 string\cf3  name)\par ??        \{\par ??            \cf1 return\cf3  resolver.Resolve&amp;lt;T&amp;gt;(name);\par ??        \}\par ??    \}\par ??\}\par ??}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;            [&lt;span style="color: yellow;"&gt;Fact&lt;/span&gt;]&lt;br /&gt;
            &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; InterceptViaCode()&lt;br /&gt;
            {&lt;br /&gt;
                &lt;span style="color: yellow;"&gt;Recorder&lt;/span&gt;.Records.Clear();&lt;br /&gt;
                &lt;span style="color: rgb(43, 145, 175);"&gt;IUnityContainer&lt;/span&gt; container = &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt; &lt;span style="color: yellow;"&gt;UnityContainer&lt;/span&gt;();&lt;br /&gt;
                container.AddNewExtension&amp;lt;&lt;span style="color: rgb(255, 255, 0);"&gt;InterceptionExtension&lt;/span&gt;&amp;gt;();&lt;br /&gt;
               container.Configure&lt;span style="color: rgb(255, 255, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;IInterceptionConfiguration&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;&amp;gt;().&lt;/span&gt;InterceptVirtual&amp;lt;&lt;span style="color: rgb(255, 255, 0);"&gt;SpyVirtual&lt;/span&gt;&amp;gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                   (&lt;span style="color: rgb(255, 153, 0);"&gt;typeof&lt;/span&gt;(&lt;span style="color: rgb(255, 255, 0);"&gt;SpyVirtual&lt;/span&gt;).GetMethod(&lt;span style="color: rgb(0, 255, 0);"&gt;"InterceptedMethod"&lt;/span&gt;), &lt;span style="color: rgb(255, 153, 0);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;RecordingHandler&lt;/span&gt;());&lt;br /&gt;
&lt;br /&gt;
                &lt;span style="color: yellow;"&gt;SpyVirtual&lt;/span&gt; obj = container.Resolve&amp;lt;&lt;span style="color: yellow;"&gt;SpyVirtual&lt;/span&gt;&amp;gt;();&lt;br /&gt;
                obj.InterceptedMethod();&lt;br /&gt;
                obj.NonInterceptedMethod();&lt;br /&gt;
&lt;br /&gt;
                &lt;span style="color: yellow;"&gt;Assert&lt;/span&gt;.Equal(4, &lt;span style="color: yellow;"&gt;Recorder&lt;/span&gt;.Records.Count);&lt;br /&gt;
                &lt;span style="color: yellow;"&gt;Assert&lt;/span&gt;.Equal(&lt;span style="color: rgb(0, 255, 0);"&gt;"Before Method"&lt;/span&gt;, &lt;span style="color: yellow;"&gt;Recorder&lt;/span&gt;.Records[0]);&lt;br /&gt;
                &lt;span style="color: yellow;"&gt;Assert&lt;/span&gt;.Equal(&lt;span style="color: rgb(0, 255, 0);"&gt;"In Method"&lt;/span&gt;, &lt;span style="color: yellow;"&gt;Recorder&lt;/span&gt;.Records[1]);&lt;br /&gt;
                &lt;span style="color: yellow;"&gt;Assert&lt;/span&gt;.Equal(&lt;span style="color: rgb(0, 255, 0);"&gt;"After Method"&lt;/span&gt;, &lt;span style="color: yellow;"&gt;Recorder&lt;/span&gt;.Records[2]);&lt;br /&gt;
                &lt;span style="color: yellow;"&gt;Assert&lt;/span&gt;.Equal(&lt;span style="color: rgb(0, 255, 0);"&gt;"In Non-Intercepted Method"&lt;/span&gt;, &lt;span style="color: yellow;"&gt;Recorder&lt;/span&gt;.Records[3]);&lt;br /&gt;
            }&lt;span style="color: rgb(255, 128, 0);"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;br /&gt;
            &lt;span style="color: rgb(255, 153, 0);"&gt;public class&lt;/span&gt; &lt;span style="color: rgb(255, 255, 0);"&gt;SpyVirtual&lt;/span&gt;&lt;br /&gt;
            {&lt;br /&gt;
                &lt;span style="color: rgb(255, 153, 0);"&gt;public virtual void&lt;/span&gt; InterceptedMethod()&lt;br /&gt;
                {&lt;br /&gt;
                    &lt;span style="color: rgb(255, 255, 0);"&gt;Recorder&lt;/span&gt;.Records.Add(&lt;span style="color: rgb(0, 255, 0);"&gt;"In Method"&lt;/span&gt;);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
                &lt;span style="color: rgb(255, 153, 0);"&gt;public void&lt;/span&gt; NonInterceptedMethod()&lt;br /&gt;
                {&lt;br /&gt;
                    &lt;span style="color: rgb(255, 255, 0);"&gt;Recorder&lt;/span&gt;.Records.Add(&lt;span style="color: rgb(0, 255, 0);"&gt;"In Non-Intercepted Method"&lt;/span&gt;);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
                &lt;span style="color: rgb(255, 153, 0);"&gt;public virtual void&lt;/span&gt; ThrowsException()&lt;br /&gt;
                {&lt;br /&gt;
                    &lt;span style="color: rgb(255, 255, 0);"&gt;Recorder&lt;/span&gt;.Records.Add(&lt;span style="color: rgb(0, 255, 0);"&gt;"In Method"&lt;/span&gt;);&lt;br /&gt;
                    &lt;span style="color: rgb(255, 153, 0);"&gt;throw new&lt;/span&gt; Exception(&lt;span style="color: rgb(0, 255, 0);"&gt;"This is my exception!"&lt;/span&gt;);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;br /&gt;
As you see above, we can simply register our interest through the registration of the InterceptionExtension and then set up the configuration through the IInterceptionConfiguration.  From that point, we then say which kind of interception we want whether it be virtual, remoting or interfaces.  We specify the method we want to intercept by name.&lt;br /&gt;
&lt;br /&gt;
You can also do the interception through the use of attributes.  From this point, we need to decorate our methods with the attribute and the particular interception handler we want to use.  We need to be aware of which interception strategy we're using as well when we decorate our classes.  You can intercept methods as well as property accessors by decorating the get or set.  Below is a simple example of a virtual interceptor registration.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green128\blue0;\red40\green40\blue40;\red255\green255\blue255;\red255\green255\blue0;\red43\green145\blue175;}??\fs16 \cf1\cb2\highlight2 namespace\cf3  UnitySamples\par ??\{\par ??    \cf1 public\cf3  \cf1 static\cf3  \cf1 class\cf3  \cf4 IoC\par ??\cf3     \{\par ??        \cf1 private\cf3  \cf1 static\cf3  \cf5 IDependencyResolver\cf3  resolver;\par ??\par ??        \cf1 public\cf3  \cf1 static\cf3  \cf1 void\cf3  Initialize(\cf5 IDependencyResolver\cf3  resolver)\par ??        \{\par ??            \cf4 IoC\cf3 .resolver = resolver;\par ??        \}\par ??\par ??        \cf1 public\cf3  \cf1 static\cf3  T Resolve&amp;lt;T&amp;gt;()\par ??        \{\par ??            \cf1 return\cf3  resolver.Resolve&amp;lt;T&amp;gt;();\par ??        \}\par ??\par ??        \cf1 public\cf3  \cf1 static\cf3  T Resolve&amp;lt;T&amp;gt;(\cf1 string\cf3  name)\par ??        \{\par ??            \cf1 return\cf3  resolver.Resolve&amp;lt;T&amp;gt;(name);\par ??        \}\par ??    \}\par ??\}\par ??}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;             &lt;span style="color: rgb(255, 153, 0);"&gt;public class&lt;/span&gt; &lt;span style="color: rgb(255, 255, 0);"&gt;SpyVirtualAttributes&lt;/span&gt;&lt;br /&gt;
            {&lt;br /&gt;
                [&lt;span style="color: rgb(255, 255, 0);"&gt;VirtualIntercept&lt;/span&gt;(&lt;span style="color: rgb(255, 153, 0);"&gt;typeof&lt;/span&gt;(&lt;span style="color: rgb(255, 255, 0);"&gt;RecordingHandler&lt;/span&gt;))]&lt;br /&gt;
                &lt;span style="color: rgb(255, 153, 0);"&gt;public virtual void&lt;/span&gt; InterceptedMethod()&lt;br /&gt;
                {&lt;br /&gt;
                    &lt;span style="color: rgb(255, 255, 0);"&gt;Recorder&lt;/span&gt;.Records.Add(&lt;span style="color: rgb(0, 255, 0);"&gt;"In Method"&lt;/span&gt;);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;/p&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;br /&gt;
I'm not going to post all of the tests, but I want to give you an idea of the power of this.  It's still early in the process and there is some cleanup still going on.  But, I encourage you to pick up the source, read it, grok it, give it a try and give feedback. &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt; Conclusion&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, the extensibility model of Unity works in that we can add interception to Unity.  So, we can start thinking about moving our cross cutting concerns to these layers should we so choose if Unity is your container of choice.  There are plenty of containers out there to choose from, so it's best to give them all a try and pick one based upon features, programming style, and heck, maybe even licensing.  I'll be showing some of this stuff off tomorrow at the CMAP Code Camp, so if you'll be at my 1PM session, be prepared.  Until next time... &lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/11/121194.aspx"&gt;&lt;img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/11/121194.aspx" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121194"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121194" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Podwysocki/aggbug/121194.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Matthew Podwysocki</dc:creator>
            <guid>http://geekswithblogs.net/Podwysocki/archive/2008/04/11/121194.aspx</guid>
            <pubDate>Fri, 11 Apr 2008 23:35:05 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Podwysocki/comments/121194.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Podwysocki/archive/2008/04/11/121194.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Podwysocki/comments/commentRss/121194.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Podwysocki/services/trackbacks/121194.aspx</trackback:ping>
        </item>
        <item>
            <title>xUnit.net RC3 Just Released</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/04/10/121177.aspx</link>
            <description>Well, &lt;a href="http://bradwilson.typepad.com/blog/"&gt;Brad Wilson&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/jamesnewkirk/"&gt;Jim Newkirk&lt;/a&gt; must really be busy lately.  After I talked about the release of xUnit.net RC2, just today, Brad announced the release of RC3.  As always, you can find the latest bits &lt;a href="http://codeplex.com/xunit"&gt;here&lt;/a&gt;.  This fixes a number of bugs and adds &lt;a href="http://ccnet.thoughtworks.com/"&gt;CruiseControl.NET&lt;/a&gt; and &lt;a href="http://asp.net/mvc/"&gt;ASP.NET MVC Preview 2&lt;/a&gt; support as well in addition to the &lt;a href="http://www.jetbrains.com/resharper/"&gt;Resharper 3.1&lt;/a&gt; and &lt;a href="http://www.testdriven.net/"&gt;TestDriven.NET&lt;/a&gt; support.  For more information about it, check out Brad's post &lt;a href="http://bradwilson.typepad.com/blog/2008/04/xunitnet-10-rc3.html"&gt;here&lt;/a&gt;.  More or less, they are feature complete for version 1.0 and the only that I think really is needed at this point is a decent GUI runner and that's well acknowledged as something they are working on.  Visual Studio integration would be nice as well...&lt;br /&gt;
&lt;br /&gt;
For my other posts in this series, check them out here:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/03/31/xunit-net-rc2-released.aspx"&gt;xUnit.net RC2 Released&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/04/04/relooking-at-xunit-net-rc2.aspx"&gt;Relooking at xUnit.net RC2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
If you were in attendance at last night's &lt;a href="http://rocknug.org/"&gt;RockNUG&lt;/a&gt; appearance, all tests for my demos were using xUnit.net, so I am actively using it right now and will be for my &lt;a href="http://www.cmap-online.org/CodeCamp/"&gt;CMAP Code Camp&lt;/a&gt; appearance this weekend.  However, I did not show the GUI runner because, well, it's not there yet, and instead, the console runner works just fine, thank you.  So, go ahead and pick up the latest bits and give the team feedback!&lt;br /&gt;
&lt;br /&gt;
One last note regarding Brad, he was &lt;a href="http://howsoftwareisbuilt.com/2008/04/08/interview-with-brad-wilson-software-developer-officelabs-microsoft/"&gt;recently interviewed&lt;/a&gt; by &lt;a href="http://howsoftwareisbuilt.com/about-scott-swigart/"&gt;Scott Swigart&lt;/a&gt; and &lt;a href="http://howsoftwareisbuilt.com/about-sean-campbell/"&gt;Sean Campbell&lt;/a&gt; over at &lt;a href="http://howsoftwareisbuilt.com"&gt;How Software Is Built&lt;/a&gt; and gives some interesting insights in the open source world inside and outside Microsoft and his contributions to it.  Very good interview and well worth the time to read.
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/10/121177.aspx"&gt;&lt;img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/10/121177.aspx" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121177"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121177" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Podwysocki/aggbug/121177.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Matthew Podwysocki</dc:creator>
            <guid>http://geekswithblogs.net/Podwysocki/archive/2008/04/10/121177.aspx</guid>
            <pubDate>Thu, 10 Apr 2008 22:37:38 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Podwysocki/comments/121177.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Podwysocki/archive/2008/04/10/121177.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Podwysocki/comments/commentRss/121177.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Podwysocki/services/trackbacks/121177.aspx</trackback:ping>
        </item>
        <item>
            <title>Unity 1.0 Released into the Wild</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/04/07/121088.aspx</link>
            <description>As &lt;a href="http://www.tavaresstudios.com/Blog/"&gt;Chris Tavares&lt;/a&gt; &lt;a href="http://www.tavaresstudios.com/Blog/post/Unity-10-is-released!.aspx"&gt;mentioned in his blog&lt;/a&gt;, &lt;a href="http://codeplex.com/unity"&gt;Unity 1.0&lt;/a&gt; has been released a couple of days earlier than the &lt;a href="http://blogs.msdn.com/agile/archive/2008/03/20/unity-release-date-changes-to-april-7.aspx"&gt;April 7th release date&lt;/a&gt; mentioned by &lt;a href="http://blogs.msdn.com/agile/"&gt;Grigori Melnik&lt;/a&gt; earlier.  &lt;a href="http://blogs.msdn.com/scottdensmore/archive/2008/04/04/unity-lives-get-your-copy-today.aspx"&gt;Scott Densmore&lt;/a&gt; also announced this as well as working on porting the inteception from ObjectBuilder2 which I talked about earlier in some of my Unity and IoC containers posts.  Looking forward to that post as we've shared some emails on the subject.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Would You Like To Know More?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
For those looking for my posts on the matter, I've covered it quite extensively with the comparison to other IoC containers as well as IoC containers in general:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/03/27/ioc-and-unity-configuration-changes-for-the-better.aspx"&gt;IoC and Unity - Configuration Changes for the Better&lt;/a&gt;&lt;br /&gt;
    Covers the latest configuration changes to allow for better constructor injection&lt;br /&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/03/25/ioc-and-unity-the-basics-and-interception.aspx"&gt;IoC and Unity - The Basics and Inteception&lt;/a&gt;&lt;br /&gt;
    Covers the basics of an IoC container and inteception techniques&lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/03/07/ioc-container-unity-and-breaking-changes-galore.aspx"&gt;IoC Container, Unity and Breaking Changes Galore&lt;/a&gt;&lt;br /&gt;
    Covers the breaking changes made from the old Unity drop to the new one&lt;br /&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/03/04/ioc-containers-unity-and-objectbuilder2-the-saga-continues.aspx"&gt;IoC Containers, Unity and ObjectBuilder2 - The Saga Continues&lt;/a&gt;&lt;br /&gt;
    Managing instances and parameter mapping resolution&lt;br /&gt;
    &lt;a href="http://geekswithblogs.net/Podwysocki/archive/2008/02/26/120002.aspx"&gt;&lt;br /&gt;
    &lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/02/26/ioc-and-the-unity-application-block-once-again.aspx"&gt;IoC and the Unity Application Block Once Again&lt;/a&gt;&lt;br /&gt;
    Setter Injection versus Constructor Injection and PostSharp4Unity&lt;br /&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/02/22/ioc-and-the-unity-application-block-going-deeper.aspx"&gt;IoC and the Unity Application Block - Going Deeper&lt;/a&gt;&lt;br /&gt;
    Constructor Injection and comparing Unity with Castle Windsor&lt;br /&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/02/18/ioc-and-the-unity-application-block.aspx"&gt;IoC and the Unity Application Block&lt;/a&gt;&lt;br /&gt;
    Covering ObjectBuilder and Unity Application Block&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Anyhow, if interesting in more Unity content, check out &lt;a href="http://codebetter.com/blogs/david.hayden/"&gt;David Hayden's&lt;/a&gt; Unity IoC and MVC screencast as well as others on the subject &lt;a href="http://codebetter.com/blogs/david.hayden/archive/2008/04/04/unity-ioc-and-asp-net-mvc-framework-screencast.aspx"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Speaking of which, I'm going to be a busy man indeed with my upcoming speaking schedule on IoC containers, not necessarily Unity in particular, but all of them, the background and decoupling your applications.  Here is the complete schedule for this month:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://www.rocknug.org/"&gt;RockNUG &lt;/a&gt;- April 9th&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.cmap-online.org/CodeCamp/"&gt;CMAP Code Camp&lt;/a&gt; - April 12th&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.cmap-online.org/Meetings/Details/2008-04-15.aspx"&gt;CMAP Architecture SIG&lt;/a&gt; - April 15th&lt;/li&gt;
&lt;/ul&gt;
I hope to contribute some at &lt;a href="http://altdotnet.org/events/seattle/"&gt;ALT.NET Open Spaces, Seattle&lt;/a&gt; as well on a few subjects and &lt;a href="http://altnet.ent0.com/"&gt;DC ALT.NET&lt;/a&gt; on April 23rd as well.  Should be a great time and feedback is always appreciated. &lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/07/121088.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/07/121088.aspx" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121088"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121088" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Podwysocki/aggbug/121088.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Matthew Podwysocki</dc:creator>
            <guid>http://geekswithblogs.net/Podwysocki/archive/2008/04/07/121088.aspx</guid>
            <pubDate>Mon, 07 Apr 2008 04:40:55 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Podwysocki/comments/121088.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Podwysocki/archive/2008/04/07/121088.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Podwysocki/comments/commentRss/121088.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Podwysocki/services/trackbacks/121088.aspx</trackback:ping>
        </item>
        <item>
            <title>Relooking at xUnit.net RC2</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/04/04/121048.aspx</link>
            <description>&lt;span style="font-weight: bold;"&gt;UPDATE: More posts on the subject&lt;br /&gt;
&lt;/span&gt;
&lt;ul&gt;
    &lt;li style="font-weight: bold;"&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/04/10/xunit-net-rc3-just-released.aspx"&gt;xUnit.net RC3 Just Released&lt;/a&gt;&lt;br /&gt;
    &lt;/li&gt;
&lt;/ul&gt;
Earlier this week, I wrote about the latest release of xUnit.net RC2.  Since that time, &lt;a href="http://bradwilson.typepad.com/"&gt;Brad Wilson&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/jamesnewkirk/"&gt;Jim Newkirk&lt;/a&gt; released a new version to fix some of the issues with regards to &lt;a href="http://www.testdriven.net/"&gt;TestDriven.NET&lt;/a&gt; integration and &lt;a href="http://asp.net/mvc/"&gt;ASP.NET MVC&lt;/a&gt; integration.    You can read more about the issues &lt;a href="http://bradwilson.typepad.com/blog/2008/04/xunitnet-rc2--1.html"&gt;here&lt;/a&gt;.  As always you can get the latest bits &lt;a href="http://www.codeplex.com/xunit/Release/ProjectReleases.aspx?ReleaseId=12209"&gt;here&lt;/a&gt;.  &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;The Installer&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
If you browse to the releases page of xUnit.net, you will notice an installer.  This installer will help integrate xUnit.net with &lt;a href="http://www.jetbrains.com/resharper/"&gt;Resharper 3.1&lt;/a&gt; for Visual Studio 2005 and 2008, TestDriven.NET and ASP.NET MVC.  Just click the installer and a screen like below will show.  Note that I have &lt;a href="http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+4.0+Nightly+Builds"&gt;Resharper 4.0 nightly builds&lt;/a&gt; instead of 3.1, so those features aren't activated just yet, unfortunately.  &lt;br /&gt;
&lt;br /&gt;
&lt;img alt="" src="http://weblogs.asp.net/blogs/podwysocki/xunitnet_installer_aspnetmvc.png" /&gt;&lt;br /&gt;
&lt;br /&gt;
Since I didn't have anything else but ASP.NET MVC Preview 2 installed, that's all I got enabled.  It only takes a few seconds to enable.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;ASP.NET MVC&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now that I got the ASP.NET MVC plugin installed for xUnit, I can go ahead and open Visual Studio 2008 and create a new ASP.NET MVC application.  When it automatically creates the test project for me, I have the option now of using xUnit.net instead of that lesser one that came in here by default.&lt;br /&gt;
&lt;br /&gt;
&lt;img src="http://weblogs.asp.net/blogs/podwysocki/aspnet_mvc_xunittests.png" alt="" /&gt;&lt;br /&gt;
&lt;br /&gt;
Once I do that, it will create some tests of the HomeController and Routes by default as noted below:&lt;br /&gt;
&lt;br /&gt;
&lt;img alt="" src="http://weblogs.asp.net/blogs/podwysocki/aspnet_mvc_solution.png" /&gt;&lt;br /&gt;
&lt;br /&gt;
But in order for this to work out of the box, there is some work you need to do.  Your tests will not compile by default because you need to change the namespace includes on top to include your application's namespace.  Not a huge issue mind you, but a little more work than usual.  Here's what it will look like:&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green128\blue0;\red40\green40\blue40;\red255\green255\blue255;\red0\green255\blue0;\red255\green255\blue0;}??\fs16 \cf1\cb2\highlight2 using\cf3  MVC_APPLICATION_NAMESPACE.Controllers; \cf4 // This using directive needs to point to the namespace of your MVC project\par ??\cf1 using\cf3  Xunit;\par ??\par ??\cf1 namespace\cf3  PetShopTests.Controllers\par ??\{\par ??    \cf1 public\cf3  \cf1 class\cf3  \cf5 HomeControllerFacts\par ??\cf3     \{\par ??        \cf1 public\cf3  \cf1 class\cf3  \cf5 Index\par ??\cf3         \{\par ??            [\cf5 Fact\cf3 ]\par ??            \cf1 public\cf3  \cf1 void\cf3  RendersTheIndexView()\par ??            \{\par ??                \cf5 TestableHomeController\cf3  controller = \cf1 new\cf3  \cf5 TestableHomeController\cf3 ();\par ??\par ??                controller.Index();\par ??\par ??                \cf5 Assert\cf3 .Equal(\cf4 "Index"\cf3 , controller.RenderView_ViewName);\par ??            \}\par ??        \}}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;using&lt;/span&gt; MVC_APPLICATION_NAMESPACE.Controllers; &lt;span style="color: lime;"&gt;// This using directive needs to point to the namespace of your MVC project&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;using&lt;/span&gt; Xunit;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;namespace&lt;/span&gt; PetShopTests.Controllers&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt; &lt;span style="color: yellow;"&gt;HomeControllerFacts&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt; &lt;span style="color: yellow;"&gt;Index&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            [&lt;span style="color: yellow;"&gt;Fact&lt;/span&gt;]&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; RendersTheIndexView()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: yellow;"&gt;TestableHomeController&lt;/span&gt; controller = &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt; &lt;span style="color: yellow;"&gt;TestableHomeController&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                controller.Index();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: yellow;"&gt;Assert&lt;/span&gt;.Equal(&lt;span style="color: lime;"&gt;"Index"&lt;/span&gt;, controller.RenderView_ViewName);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
So, all you need to do is replace the &lt;span style="font-weight: bold;"&gt;MVC_APPLICATION_NAMESPACE&lt;/span&gt; with your own namespace and problem solved!  But out of the box, you have some working unit tests and some good guidance on how to get started.  If you're curious on how the integration actually works, check out this post &lt;a href="http://blogs.msdn.com/webdevtools/archive/2008/03/06/asp-net-mvc-test-framework-integration-demo.aspx"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;GUI Runner&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As Brad had stated earlier, there is a simple, yet effective GUI runner for xUnit.net.  So far there's not much to it, other than to load an assembly and run all associated tests.  To give you an example, I wrote some F# code and now I want to run some tests against it.  So, here is the code I used for these simple tests.  Yes, you can go ahead and yell at me for doing OO things in a functional language, but it's here to prove a point that you can.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
#R @&lt;span style="color: rgb(0, 255, 0);"&gt;"E:\Tools\xunit-build-1223-samples\Samples\xunit\xunit.dll" &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;open&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;System&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;open&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;System.Collections.Generic&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;open&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Xunit&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type &lt;/span&gt;Stack&amp;lt;'t&amp;gt; = &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt;&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;val&lt;/span&gt; elements : LinkedList&amp;lt;'t&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  new() = { elements = &lt;span style="color: rgb(255, 128, 0);"&gt;new &lt;/span&gt;LinkedList&amp;lt;'t&amp;gt;() }&lt;br /&gt;
  &lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;x.IsEmpty&lt;br /&gt;
    &lt;span style="color: rgb(255, 128, 0);"&gt;with &lt;/span&gt;get() = x.elements.Count = 0&lt;br /&gt;
    &lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;x.Push element =&lt;br /&gt;
    x.elements.AddFirst(element:'t)&lt;br /&gt;
    &lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;x.Top&lt;br /&gt;
    &lt;span style="color: rgb(255, 128, 0);"&gt;with &lt;/span&gt;get() =&lt;br /&gt;
      &lt;span style="color: rgb(255, 128, 0);"&gt;if &lt;/span&gt;x.elements.Count = 0 &lt;span style="color: rgb(255, 128, 0);"&gt;then&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
        raise (InvalidOperationException(&lt;span style="color: rgb(0, 255, 0);"&gt;"cannot top an empty stack"&lt;/span&gt;))&lt;br /&gt;
      x.elements.First.Value&lt;br /&gt;
      &lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;x.Pop = &lt;br /&gt;
    &lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;top = x.Top&lt;br /&gt;
    x.elements.RemoveFirst()&lt;br /&gt;
    top&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
[&amp;lt;Fact&amp;gt;]   &lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;NoElementsShouldBeEmpty () =&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;stack = new Stack&amp;lt;string&amp;gt;()&lt;br /&gt;
  Assert.True(stack.IsEmpty)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;[&amp;lt;Fact&amp;gt;]&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;PushAnElementShouldNotBeEmpty() =&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;stack = new Stack&amp;lt;string&amp;gt;()&lt;br /&gt;
  stack.Push(&lt;span style="color: rgb(0, 255, 0);"&gt;"first element"&lt;/span&gt;)&lt;br /&gt;
  Assert.False(stack.IsEmpty)&lt;br /&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
And now, open the xunit.gui.exe and select your assembly you want to run.  I chose my fsharpsamples.dll that I've been working with on my F# samples.  Now, let's give these two tests a run to see how they do.&lt;br /&gt;
&lt;br /&gt;
&lt;img src="http://weblogs.asp.net/blogs/podwysocki/xunitnet_guirunner_greenlight.png" alt="" /&gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, not much information is given to me other than the number of passed tests, the time taken and my assembly under test.  Not much information, but enough to get started.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, a bit of progress has been made on xUnit.net and here's hoping the version 1.0 full release is coming soon.  As I look at it more and more, I'm definitely starting to like it.  I haven't had to create as many extensions as I would have to do with MSTest such as Assert.Throws&amp;lt;T&amp;gt; and so on.  So, I encourage you to go ahead and once again, give it a look and give feedback to the team.  Until next time... &lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/04/121048.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/04/121048.aspx" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121048"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121048" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Podwysocki/aggbug/121048.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Matthew Podwysocki</dc:creator>
            <guid>http://geekswithblogs.net/Podwysocki/archive/2008/04/04/121048.aspx</guid>
            <pubDate>Fri, 04 Apr 2008 22:34:24 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Podwysocki/comments/121048.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Podwysocki/archive/2008/04/04/121048.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Podwysocki/comments/commentRss/121048.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Podwysocki/services/trackbacks/121048.aspx</trackback:ping>
        </item>
        <item>
            <title>Covering NUnit 2.4.7</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/04/01/120934.aspx</link>
            <description>It's interesting that a flurry of releases of testing frameworks have been released lately with &lt;a href="http://www.gallio.org/"&gt;Gallio&lt;/a&gt;, &lt;a href="http://codeplex.com/xunit"&gt;xUnit.net&lt;/a&gt; and of course &lt;a href="http://nunit.com/index.php"&gt;NUnit&lt;/a&gt;.&lt;a href="http://blogs.nunit.com/"&gt;  Charlie Poole&lt;/a&gt; recently announced on a lot of the discussion boards I belong to recently that &lt;a href="http://nunit.com/index.php?p=download"&gt;NUnit 2.4.7&lt;/a&gt; was recently released.  You can read all about what's been added &lt;a href="http://nunit.com/index.php?p=releaseNotes&amp;amp;r=2.4.7"&gt;here &lt;/a&gt;with the release notes.  &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;What's New and Interesting?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
What's interesting about this release?  Well, NUnit no longer depends on log4net, thus getting rid of some dependency issues with regards to the applications under test.  What's also interesting is that addition of the RowTest extension to allow  multiple sets of arguments to be given to a test.  This is the first one that's ever been incorporated into the core of NUnit.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Static Tests in NUnit?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As &lt;a href="http://weblogs.asp.net/astopford/"&gt;Andy Stopford&lt;/a&gt; noted in my blog yesterday regarding xUnit.net, &lt;a href="http://sourceforge.net/mailarchive/forum.php?thread_name=004401c887ad%249e816030%246501a8c0%40ferrari&amp;amp;forum_name=nunit-developer"&gt;Charlie recently checked in code&lt;/a&gt; to allow static methods for static methods to be tests as well as Setup and TearDown to be static as well.  Jim Newkirk, the man behind NUnit and co-creator of xUnit.net, favors that approach of allowing statics.  To me, I don't care as much with regards to Startup and TearDown with statics as most of my statics for testing F# is side effect free programming.  As it should be with functional programming.  Anyhow, what I'd like to see in NUnit is the support for something that I can do in xUnit.net:&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
#R &lt;span style="color: rgb(0, 255, 0);"&gt;@"D:\Program Files\NUnit 2.4.7\bin\nunit.core.dll"&lt;/span&gt;&lt;br /&gt;
#R &lt;span style="color: rgb(0, 255, 0);"&gt;@"D:\Program Files\NUnit 2.4.7\bin\nunit.framework.dll"&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;open&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;NUnit.Framework&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;rec&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;fib n =&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;match&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;n &lt;span style="color: rgb(255, 128, 0);"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;with&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
  | 0 | 1 &lt;span style="color: rgb(255, 128, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;&lt;/span&gt; 0&lt;br /&gt;
  | n &lt;span style="color: rgb(255, 128, 0);"&gt;-&amp;gt;&lt;/span&gt; fib(n-2) + fib(n-1)&lt;br /&gt;
  | n &lt;span style="color: rgb(255, 128, 0);"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;when&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt; n &amp;lt; 0 &lt;span style="color: rgb(255, 128, 0);"&gt;-&amp;gt;&lt;/span&gt; failwith &lt;span style="color: rgb(0, 255, 0);"&gt;"Cannot be less than zero"&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
[&amp;lt;TestFixture&amp;gt;]&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;&lt;/span&gt;FibOfOneShouldReturnZero() =&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;&lt;/span&gt;fibResult = fib(1)&lt;br /&gt;
  Assert.AreEqual(fibResult, 0)&lt;br /&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
If I saw something like this, I'd be a happy man.  But until then, I can dream...&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Go ahead and pick up your copy today of NUnit.  It's been the old standby for many of my projects throughout my career and served me quite well.  Next time I'll cover Gallio a little bit as I have neglected it, but it's a huge release.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/01/120934.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/01/120934.aspx" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=120934"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=120934" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Podwysocki/aggbug/120934.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Matthew Podwysocki</dc:creator>
            <guid>http://geekswithblogs.net/Podwysocki/archive/2008/04/01/120934.aspx</guid>
            <pubDate>Tue, 01 Apr 2008 21:34:37 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Podwysocki/comments/120934.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Podwysocki/archive/2008/04/01/120934.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Podwysocki/comments/commentRss/120934.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Podwysocki/services/trackbacks/120934.aspx</trackback:ping>
        </item>
        <item>
            <title>IoC and Unity - The Basics and InterceptionIoC and Unity - The Basics and Interception</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/03/26/120764.aspx</link>
            <description>I realize it's been a while since my last post on &lt;a href="http://en.wikipedia.org/wiki/Inversion_of_control"&gt;Inversion of Control&lt;/a&gt; containers and looking at Unity as one of them.  Since that time, &lt;a href="http://www.hanselman.com/blog/" mce_href="http://www.hanselman.com/blog/"&gt;Scott Hanselman&lt;/a&gt; linked to some of the comparisons that I did for IoC containers &lt;a href="http://www.hanselman.com/blog/ListOfNETDependencyInjectionContainersIOC.aspx" mce_href="http://www.hanselman.com/blog/ListOfNETDependencyInjectionContainersIOC.aspx"&gt;here&lt;/a&gt;.  I'll be the first to admit that the look was a bit naive, but to get you all interested in looking at IoC container and how they can improve your applications.  It was suggested &lt;a href="http://www.ayende.com/Blog/archive/2008/03/14/Evaluating-IoC-containers.aspx" mce_href="http://www.ayende.com/Blog/archive/2008/03/14/Evaluating-IoC-containers.aspx"&gt;here &lt;/a&gt;that my posts weren't a complete comparison, although in my previous posts I covered a lot of those topics.  Even so, after talking with &lt;a href="http://www.ayende.com/"&gt;said individual&lt;/a&gt;, I need to cover more ground on the basics and dive deeper into the details.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt; Where We Are&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Before we begin today, let's see what we've already covered in the past:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/03/07/ioc-container-unity-and-breaking-changes-galore.aspx"&gt;IoC Container, Unity and Breaking Changes Galore&lt;/a&gt;&lt;br /&gt;
    Covers the breaking changes made from the old Unity drop to the new one&lt;br /&gt;
    &lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/03/04/ioc-containers-unity-and-objectbuilder2-the-saga-continues.aspx"&gt;&lt;br /&gt;
    &lt;/a&gt;     &lt;/li&gt;
    &lt;li&gt;&lt;a href="javascript:void(0);/*1206509408817*/"&gt;IoC Containers, Unity and ObjectBuilder2 - The Saga Continues&lt;/a&gt;&lt;br /&gt;
    Managing instances and parameter mapping resolution&lt;br /&gt;
    &lt;a href="http://geekswithblogs.net/Podwysocki/archive/2008/02/26/120002.aspx"&gt;&lt;br /&gt;
    &lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/02/26/ioc-and-the-unity-application-block-once-again.aspx"&gt;IoC and the Unity Application Block Once Again&lt;/a&gt;&lt;br /&gt;
    Setter Injection versus Constructor Injection and PostSharp4Unity&lt;br /&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/02/22/ioc-and-the-unity-application-block-going-deeper.aspx"&gt;IoC and the Unity Application Block - Going Deeper&lt;/a&gt;&lt;br /&gt;
    Constructor Injection and comparing Unity with Castle Windsor&lt;br /&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/02/18/ioc-and-the-unity-application-block.aspx"&gt;IoC and the Unity Application Block&lt;/a&gt;&lt;br /&gt;
    Covering ObjectBuilder and Unity Application Block&lt;/li&gt;
&lt;/ul&gt;
So, we have a bit of back history, but I think I dived too far into things without giving some of the back story.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt; DI Frameworks Galore&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As Scott Hanselman noted, there are a number of IoC containers in the .NET Space.  Most of these I was already aware of and played with, so I'm only going to list the ones I've played with.  Here they are in no particular order:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://www.castleproject.org/container/index.html"&gt;Castle Windsor&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://structuremap.sourceforge.net/"&gt;StructureMap&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.springframework.net/"&gt;Spring.NET&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.codeplex.com/ObjectBuilder/SourceControl/DownloadSourceCode.aspx?changeSetId=29957"&gt;ObjectBuilder2 CodePlex Container&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://codeplex.com/unity"&gt;Unity Application Block&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.codeproject.com/KB/cs/LinFuPart1.aspx"&gt;LinFu&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://ninject.org/"&gt;NInject&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://code.google.com/p/autofac/"&gt;AutoFac&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.puzzleframework.com/"&gt;Puzzle.NET&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://s2container.net.seasar.org/en/index.html"&gt;S2Container.NET&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
So, as you can see, there are plenty to choose from.  They all serve basic IoC needs and I'll talk about that a little bit more later.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt; Getting Back to Basics&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
When we talk about Inversion of Control and &lt;a href="http://en.wikipedia.org/wiki/Dependency_inversion_principle"&gt;dependency inversion principle&lt;/a&gt;, we're talking about loosely coupled applications.  It follows the &lt;a href="http://en.wikipedia.org/wiki/Hollywood_Principle"&gt;Hollywood Principle&lt;/a&gt; which is the trite "Don't call use, we'll call you" mantra.  In a way it means that those dependencies that you have inside your class, say your Logger and its associated formatter.  In the tightly coupled world, you would have a private member of a Logger.  Instead, what you would have in the other case is an interface or abstract class that would represent the functionality of that logger, and that instance given to your class.  Throw on top of that a container to manage those dependencies to those interfaces and mappings to concrete classes.  Also, your container can manage the object lifetimes as well.   &lt;a href="http://www.ayende.com/"&gt;Ayende&lt;/a&gt; shows how easy it is to &lt;a href="http://www.ayende.com/Blog/archive/2007/10/20/Building-an-IoC-container-in-15-lines-of-code.aspx"&gt;create a simple container&lt;/a&gt;, although it misses an important point about lifetime management.&lt;br /&gt;
&lt;br /&gt;
To put it succinctly, to be a container should satisfy the following requirements:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;Configuration - Registering types and mappings through code, XML or script&lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Lifetime Management - How the lifetime of the objects are managed, singleton, transient, etc&lt;/li&gt;
    &lt;li&gt;Resolution - Resolve dependencies and instantiate&lt;/li&gt;
    &lt;li&gt;Extensibility - Be able to add new facilities for additional features (interception, AOP, and so on)&lt;/li&gt;
&lt;/ul&gt;
Before we get into any advanced topics, let's get into more detail.  &lt;a href="http://codebetter.com/blogs/james.kovacs/default.aspx"&gt;James Kovacs&lt;/a&gt; wrote in the March 2008 edition of MSDN Magazine called &lt;a href="http://msdn2.microsoft.com/en-ca/magazine/cc337885.aspx"&gt;"Loosen Up - Tame Your Software Dependencies For More Flexible Apps"&lt;/a&gt;.   This article is a great start for those trying to understand dependency inversion and dependency injection.  James walks through a simple application with tight coupling, and then works to loosen it.  Once that is complete, Castle Windsor is introduced and walks through the XML configuration or using Binsor to auto-wire the container.&lt;br /&gt;
&lt;br /&gt;
One of the more key points in this article and it came from Ayende is to have an anti-corruption layer for your IoC container.  Yes, that's the same Domain Driven Design term in which we isolate things that don't conform to our given architecture and can translate from one context to another.  Let's throw up a simple example of using this.  Remember it's just a quick spike of an anti-corruption layer.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green128\blue0;\red40\green40\blue40;\red255\green255\blue255;\red255\green255\blue0;\red43\green145\blue175;}??\fs16 \cf1\cb2\highlight2 namespace\cf3  UnitySamples\par ??\{\par ??    \cf1 public\cf3  \cf1 static\cf3  \cf1 class\cf3  \cf4 IoC\par ??\cf3     \{\par ??        \cf1 private\cf3  \cf1 static\cf3  \cf5 IDependencyResolver\cf3  resolver;\par ??\par ??        \cf1 public\cf3  \cf1 static\cf3  \cf1 void\cf3  Initialize(\cf5 IDependencyResolver\cf3  resolver)\par ??        \{\par ??            \cf4 IoC\cf3 .resolver = resolver;\par ??        \}\par ??\par ??        \cf1 public\cf3  \cf1 static\cf3  T Resolve&amp;lt;T&amp;gt;()\par ??        \{\par ??            \cf1 return\cf3  resolver.Resolve&amp;lt;T&amp;gt;();\par ??        \}\par ??\par ??        \cf1 public\cf3  \cf1 static\cf3  T Resolve&amp;lt;T&amp;gt;(\cf1 string\cf3  name)\par ??        \{\par ??            \cf1 return\cf3  resolver.Resolve&amp;lt;T&amp;gt;(name);\par ??        \}\par ??    \}\par ??\}\par ??}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;namespace&lt;/span&gt; UnitySamples&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt; &lt;span style="color: yellow;"&gt;IoC&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IDependencyResolver&lt;/span&gt; resolver;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; Initialize(&lt;span style="color: rgb(43, 145, 175);"&gt;IDependencyResolver&lt;/span&gt; resolver)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: yellow;"&gt;IoC&lt;/span&gt;.resolver = resolver;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;static&lt;/span&gt; T Resolve&amp;lt;T&amp;gt;()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;return&lt;/span&gt; resolver.Resolve&amp;lt;T&amp;gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;static&lt;/span&gt; T Resolve&amp;lt;T&amp;gt;(&lt;span style="color: rgb(255, 128, 0);"&gt;string&lt;/span&gt; name)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;return&lt;/span&gt; resolver.Resolve&amp;lt;T&amp;gt;(name);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
So, what we have is an IDependencyResolver given to the singleton IoC container.  Like I said, this isn't best practice as I haven't done any checking on whether the resolver was initialized or not.  But, what we want is to expose the way of resolving dependencies.  Now let's take a look at the IDependencyResolver interface and how that's used.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green128\blue0;\red40\green40\blue40;\red255\green255\blue255;\red43\green145\blue175;}??\fs16 \cf1\cb2\highlight2 namespace\cf3  UnitySamples\par ??\{\par ??    \cf1 public\cf3  \cf1 interface\cf3  \cf4 IDependencyResolver\par ??\cf3     \{\par ??        T Resolve&amp;lt;T&amp;gt;(\cf1 string\cf3  name);\par ??\par ??        T Resolve&amp;lt;T&amp;gt;();\par ??    \}\par ??\}\par ??}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;namespace&lt;/span&gt; UnitySamples&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;interface&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IDependencyResolver&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        T Resolve&amp;lt;T&amp;gt;(&lt;span style="color: rgb(255, 128, 0);"&gt;string&lt;/span&gt; name);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        T Resolve&amp;lt;T&amp;gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
Not much to this but gives us the ability to resolve our dependencies by type, or by type and name.  Pretty simple code here once again.  But, if I wanted to suddenly use Unity as the backing store, I'd simply implement it as the following:&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green128\blue0;\red40\green40\blue40;\red255\green255\blue255;\red255\green255\blue0;\red43\green145\blue175;\red0\green255\blue0;}??\fs16 \cf1\cb2\highlight2 using\cf3  System.Configuration;\par ??\cf1 using\cf3  Microsoft.Practices.Unity;\par ??\cf1 using\cf3  Microsoft.Practices.Unity.Configuration;\par ??\par ??\cf1 namespace\cf3  UnitySamples\par ??\{\par ??    \cf1 public\cf3  \cf1 class\cf3  \cf4 UnityDependencyResolver\cf3 : \cf5 IDependencyResolver\par ??\cf3     \{\par ??        \cf1 private\cf3  \cf5 IUnityContainer\cf3  container;\par ??\par ??        \cf1 public\cf3  UnityDependencyResolver()\par ??        \{\par ??            container = \cf1 new\cf3  \cf4 UnityContainer\cf3 ();\par ??            \cf4 UnityConfigurationSection\cf3  section = (\cf4 UnityConfigurationSection\cf3 )\cf4 ConfigurationManager\cf3 .GetSection(\cf6 "unity"\cf3 );\par ??            section.Containers.Default.GetConfigCommand().Configure(container);\par ??        \}\par ??\par ??        \cf1 public\cf3  T Resolve&amp;lt;T&amp;gt;()\par ??        \{\par ??            \cf1 return\cf3  container.Resolve&amp;lt;T&amp;gt;();\par ??        \}\par ??\par ??        \cf1 public\cf3  T Resolve&amp;lt;T&amp;gt;(\cf1 string\cf3  name)\par ??        \{\par ??            \cf1 return\cf3  container.Resolve&amp;lt;T&amp;gt;(name);\par ??        \}\par ??    \}\par ??\}\par ??}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;using&lt;/span&gt; System.Configuration;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;using&lt;/span&gt; Microsoft.Practices.Unity;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;using&lt;/span&gt; Microsoft.Practices.Unity.Configuration;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;namespace&lt;/span&gt; UnitySamples&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt; &lt;span style="color: yellow;"&gt;UnityDependencyResolver&lt;/span&gt;: &lt;span style="color: rgb(43, 145, 175);"&gt;IDependencyResolver&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IUnityContainer&lt;/span&gt; container;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; UnityDependencyResolver()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            container = &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt; &lt;span style="color: yellow;"&gt;UnityContainer&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: yellow;"&gt;UnityConfigurationSection&lt;/span&gt; section = (&lt;span style="color: yellow;"&gt;UnityConfigurationSection&lt;/span&gt;)&lt;span style="color: yellow;"&gt;ConfigurationManager&lt;/span&gt;.GetSection(&lt;span style="color: lime;"&gt;"unity"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            section.Containers.Default.GetConfigCommand().Configure(container);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; T Resolve&amp;lt;T&amp;gt;()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;return&lt;/span&gt; container.Resolve&amp;lt;T&amp;gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; T Resolve&amp;lt;T&amp;gt;(&lt;span style="color: rgb(255, 128, 0);"&gt;string&lt;/span&gt; name)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;return&lt;/span&gt; container.Resolve&amp;lt;T&amp;gt;(name);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
So, all I'd have to do to switch from one container to another is just swap out the IDependencyResolver and I'm finished.  But, unfortunately, there are some techniques that are partial to one container or another, so there may be some things I'd lose there.  But for most cases, this pattern works and works well at that.&lt;br /&gt;
&lt;br /&gt;
Of course loose coupling, dependency injection and using IoC containers are nice in terms of making unit tests easier, but as you can see, there's a bit more to it than that, including the lifetime management, interception, the flexibility of changing implementations and so on.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt; Interception and Aspect Oriented Programming&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://en.wikipedia.org/wiki/Aspect_oriented_programming"&gt;Aspect Oriented Programming (AOP)&lt;/a&gt; and basic interception are interesting pieces of some containers.  This technique allows us to handle cross-cutting concerns such as logging, transaction management, security and so on at a different level instead of littering our code and domain model with checks everywhere.  Instead, we centralize those concerns and have them intercept calls and do their work.  Let's get some jargon straight here before we go any further.  An &lt;span style="font-weight: bold;"&gt;aspect &lt;/span&gt;is the part that encapsulates the cross-cutting concern such as logging.  These aspects can give advice, which is to alter the behavior of a given program.  The &lt;span style="font-weight: bold;"&gt;advice &lt;/span&gt;is given at certain &lt;span style="font-weight: bold;"&gt;join points&lt;/span&gt; which is where the aspect advice and the program intersect.  A group of these join points are called a &lt;span style="font-weight: bold;"&gt;pointcut&lt;/span&gt;. &lt;br /&gt;
&lt;br /&gt;
Interception is a feature of some of the IoC containers out there.  A few come to mind such as Castle Windsor, Spring.NET, LinFu, S2Container, Puzzle.NET and even ObjectBuilder2.  These containers provide at least a basic level of interception, meaning that you can intercept calls to methods, analyze the contents of the method call, proceed with the call and even modify the return value.  Since most containers support simple interception, I haven't found it more useful than logging or enforcing security on various things.  However, it can be extended to support more robust Policy Injection style of programming such as you would find in the &lt;a href="http://msdn2.microsoft.com/en-us/library/bb410104.aspx"&gt;Policy Injection Application Block&lt;/a&gt;.&lt;br /&gt;
&lt;br style="font-weight: bold;" /&gt;
&lt;span style="font-weight: bold;"&gt; Interception in Unity?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Quite a bit has changed with Unity since I last blogged about it in terms of the configuration.  You can grab the latest bits &lt;a href="http://www.codeplex.com/unity/Release/ProjectReleases.aspx?ReleaseId=11956"&gt;here&lt;/a&gt;.  It would be nice to have changesets and such checked into CodePlex for things like this instead of zip files or MSIs, but oh well.  Anyhow, most of the changes revolve around managing lifetimes and handling the parameters for constructor injection.  You can read the tests and figure it out.&lt;br /&gt;
&lt;br /&gt;
As I've covered before, right now simple injection in Unity is not supported at the moment.  The intention is to have the Policy Injection Application Block fill that role.  There is also PostSharp4Unity which can also fit that bill for quick fixes, but I want deep down support for simple interception.  Conversations with &lt;a href="http://bradwilson.typepad.com/"&gt;Brad Wilson&lt;/a&gt; led me to ObjectBuilder2 and some spikes that they had with a customer DependencyContainer.  So parts of me wondered why that wasn't leveraged at all.  Let's take a look at what was implemented in the base of ObjectBuilder2.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt; Interception in ObjectBuilder2&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
ObjectBuilder2 was a project by Brad Wilson and &lt;a href="http://blogs.msdn.com/scottdensmore/"&gt;Scott Densmore&lt;/a&gt; which took the original ObjectBuilder, which was really meant for CAB and not a real container, and made some changes and improvements.  Such improvements also came with a few samples of things you can do with it such as a DependencyContainer sample.  In here, there are a few interesting pieces.  Most of which lie in the interception pieces.  Let's take a look at each type below of the ones supported.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;\red255\green255\blue0;\red43\green145\blue175;}??\fs16 \cf1\cb2\highlight2         \cf3 public\cf1  \cf3 void\cf1  InterceptInterface&amp;lt;T&amp;gt;(\cf4 MethodInfo\cf1  interfaceMethod,\par ??                                          \cf3 params\cf1  \cf5 IInterceptionHandler\cf1 [] handlers)\par ??        \{\par ??            Intercept&amp;lt;\cf4 InterfaceInterceptionPolicy\cf1 , \cf5 IInterfaceInterceptionPolicy\cf1 &amp;gt;(\cf3 typeof\cf1 (T), interfaceMethod, handlers);\par ??        \}\par ??\par ??        \cf3 public\cf1  \cf3 void\cf1  InterceptInterface(\cf4 Type\cf1  typeToIntercept,\par ??                                       \cf4 MethodInfo\cf1  interfaceMethod,\par ??                                       \cf3 params\cf1  \cf5 IInterceptionHandler\cf1 [] handlers)\par ??        \{\par ??            Intercept&amp;lt;\cf4 InterfaceInterceptionPolicy\cf1 , \cf5 IInterfaceInterceptionPolicy\cf1 &amp;gt;(typeToIntercept, interfaceMethod, handlers);\par ??        \}\par ??\par ??        \cf3 public\cf1  \cf3 void\cf1  InterceptRemoting&amp;lt;T&amp;gt;(\cf4 MethodInfo\cf1  method,\par ??                                         \cf3 params\cf1  \cf5 IInterceptionHandler\cf1 [] handlers)\par ??        \{\par ??            Intercept&amp;lt;\cf4 RemotingInterceptionPolicy\cf1 , \cf5 IRemotingInterceptionPolicy\cf1 &amp;gt;(\cf3 typeof\cf1 (T), method, handlers);\par ??        \}\par ??\par ??        \cf3 public\cf1  \cf3 void\cf1  InterceptRemoting(\cf4 Type\cf1  typeToIntercept,\par ??                                      \cf4 MethodInfo\cf1  method,\par ??                                      \cf3 params\cf1  \cf5 IInterceptionHandler\cf1 [] handlers)\par ??        \{\par ??            Intercept&amp;lt;\cf4 RemotingInterceptionPolicy\cf1 , \cf5 IRemotingInterceptionPolicy\cf1 &amp;gt;(typeToIntercept, method, handlers);\par ??        \}\par ??\par ??        \cf3 public\cf1  \cf3 void\cf1  InterceptVirtual&amp;lt;T&amp;gt;(\cf4 MethodInfo\cf1  method,\par ??                                        \cf3 params\cf1  \cf5 IInterceptionHandler\cf1 [] handlers)\par ??        \{\par ??            Intercept&amp;lt;\cf4 VirtualInterceptionPolicy\cf1 , \cf5 IVirtualInterceptionPolicy\cf1 &amp;gt;(\cf3 typeof\cf1 (T), method, handlers);\par ??        \}\par ??\par ??        \cf3 public\cf1  \cf3 void\cf1  InterceptVirtual(\cf4 Type\cf1  typeToIntercept,\par ??                                     \cf4 MethodInfo\cf1  method,\par ??                                     \cf3 params\cf1  \cf5 IInterceptionHandler\cf1 [] handlers)\par ??        \{\par ??            Intercept&amp;lt;\cf4 VirtualInterceptionPolicy\cf1 , \cf5 IVirtualInterceptionPolicy\cf1 &amp;gt;(typeToIntercept, method, handlers);\par ??        \}}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; InterceptInterface&amp;lt;T&amp;gt;(&lt;span style="color: yellow;"&gt;MethodInfo&lt;/span&gt; interfaceMethod,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                                          &lt;span style="color: rgb(255, 128, 0);"&gt;params&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IInterceptionHandler&lt;/span&gt;[] handlers)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; InterceptInterface(&lt;span style="color: yellow;"&gt;Type&lt;/span&gt; typeToIntercept,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                                       &lt;span style="color: yellow;"&gt;MethodInfo&lt;/span&gt; interfaceMethod,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                                       &lt;span style="color: rgb(255, 128, 0);"&gt;params&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IInterceptionHandler&lt;/span&gt;[] handlers)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; InterceptRemoting&amp;lt;T&amp;gt;(&lt;span style="color: yellow;"&gt;MethodInfo&lt;/span&gt; method,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                                         &lt;span style="color: rgb(255, 128, 0);"&gt;params&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IInterceptionHandler&lt;/span&gt;[] handlers)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; InterceptRemoting(&lt;span style="color: yellow;"&gt;Type&lt;/span&gt; typeToIntercept,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                                      &lt;span style="color: yellow;"&gt;MethodInfo&lt;/span&gt; method,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                                      &lt;span style="color: rgb(255, 128, 0);"&gt;params&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IInterceptionHandler&lt;/span&gt;[] handlers)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; InterceptVirtual&amp;lt;T&amp;gt;(&lt;span style="color: yellow;"&gt;MethodInfo&lt;/span&gt; method,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                                        &lt;span style="color: rgb(255, 128, 0);"&gt;params&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IInterceptionHandler&lt;/span&gt;[] handlers)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; InterceptVirtual(&lt;span style="color: yellow;"&gt;Type&lt;/span&gt; typeToIntercept,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                                     &lt;span style="color: yellow;"&gt;MethodInfo&lt;/span&gt; method,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                                     &lt;span style="color: rgb(255, 128, 0);"&gt;params&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IInterceptionHandler&lt;/span&gt;[] handlers)&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
Now with this, you can see there are three different ways of intercepting, through interfaces, virtual methods or through remoting.  We also have the ability to intercept through attributes or through code.  Let's walk through a test to see how intercepting through attributes might work.  &lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green255\blue0;\red255\green128\blue0;\red43\green145\blue175;\red0\green255\blue0;}??\fs16 \cf1\cb2\highlight2             [\cf3 Fact\cf1 ]\par ??            \cf4 public\cf1  \cf4 void\cf1  InterceptViaAttributes()\par ??            \{\par ??                \cf3 Recorder\cf1 .Records.Clear();\par ??                \cf3 DependencyContainer\cf1  container = \cf4 new\cf1  \cf3 DependencyContainer\cf1 ();\par ??                container.RegisterTypeMapping&amp;lt;\cf5 ISpy\cf1 , \cf3 SpyInterfaceAttributes\cf1 &amp;gt;();\par ??\par ??                \cf5 ISpy\cf1  obj = container.Get&amp;lt;\cf5 ISpy\cf1 &amp;gt;();\par ??                obj.InterceptedMethod();\par ??\par ??                \cf3 Assert\cf1 .Equal(3, \cf3 Recorder\cf1 .Records.Count);\par ??                \cf3 Assert\cf1 .Equal(\cf6 "Before Method"\cf1 , \cf3 Recorder\cf1 .Records[0]);\par ??                \cf3 Assert\cf1 .Equal(\cf6 "In Method"\cf1 , \cf3 Recorder\cf1 .Records[1]);\par ??                \cf3 Assert\cf1 .Equal(\cf6 "After Method"\cf1 , \cf3 Recorder\cf1 .Records[2]);\par ??            \}}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;            [&lt;span style="color: yellow;"&gt;Fact&lt;/span&gt;]&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; InterceptViaAttributes()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: yellow;"&gt;Recorder&lt;/span&gt;.Records.Clear();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: yellow;"&gt;DependencyContainer&lt;/span&gt; container = &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt; &lt;span style="color: yellow;"&gt;DependencyContainer&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                container.RegisterTypeMapping&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;ISpy&lt;/span&gt;, &lt;span style="color: yellow;"&gt;SpyInterfaceAttributes&lt;/span&gt;&amp;gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: rgb(43, 145, 175);"&gt;ISpy&lt;/span&gt; obj = container.Get&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;ISpy&lt;/span&gt;&amp;gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                obj.InterceptedMethod();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: yellow;"&gt;Assert&lt;/span&gt;.Equal(3, &lt;span style="color: yellow;"&gt;Recorder&lt;/span&gt;.Records.Count);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: yellow;"&gt;Assert&lt;/span&gt;.Equal(&lt;span style="color: lime;"&gt;"Before Method"&lt;/span&gt;, &lt;span style="color: yellow;"&gt;Recorder&lt;/span&gt;.Records[0]);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: yellow;"&gt;Assert&lt;/span&gt;.Equal(&lt;span style="color: lime;"&gt;"In Method"&lt;/span&gt;, &lt;span style="color: yellow;"&gt;Recorder&lt;/span&gt;.Records[1]);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: yellow;"&gt;Assert&lt;/span&gt;.Equal(&lt;span style="color: lime;"&gt;"After Method"&lt;/span&gt;, &lt;span style="color: yellow;"&gt;Recorder&lt;/span&gt;.Records[2]);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            }&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
Of course there wouldn't be tests in here without using &lt;a href="http://www.codeplex.com/xunit"&gt;xUnit.NET&lt;/a&gt; of course.  Hope to cover that soon enough.  Anyhow, as you can see, it's pretty simple to register types in here and then check the expectations through the recorder to see whether the actions happened.  To find out what the ISpy and SpyInterfaceAttribtues are actually doing, let's dig through the code.  &lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;\red43\green145\blue175;\red255\green255\blue0;\red0\green255\blue0;}??\fs16 \cf1\cb2\highlight2             \cf3 public\cf1  \cf3 interface\cf1  \cf4 ISpy\par ??\cf1             \{\par ??                \cf3 void\cf1  InterceptedMethod();\par ??                \cf3 void\cf1  ThrowsException();\par ??            \}\par ??\par ??            \cf3 internal\cf1  \cf3 sealed\cf1  \cf3 class\cf1  \cf5 SpyInterface\cf1  : \cf4 ISpy\par ??\cf1             \{\par ??                \cf3 public\cf1  \cf3 void\cf1  InterceptedMethod()\par ??                \{\par ??                    \cf5 Recorder\cf1 .Records.Add(\cf6 "In Method"\cf1 );\par ??                \}\par ??\par ??                \cf3 public\cf1  \cf3 void\cf1  ThrowsException()\par ??                \{\par ??                    \cf5 Recorder\cf1 .Records.Add(\cf6 "In Method"\cf1 );\par ??                    \cf3 throw\cf1  \cf3 new\cf1  \cf5 Exception\cf1 ();\par ??                \}\par ??            \}\par ??\par ??            \cf3 internal\cf1  \cf3 sealed\cf1  \cf3 class\cf1  \cf5 SpyInterfaceAttributes\cf1  : \cf4 ISpy\par ??\cf1             \{\par ??                [\cf5 InterfaceIntercept\cf1 (\cf3 typeof\cf1 (\cf5 RecordingHandler\cf1 ))]\par ??                \cf3 public\cf1  \cf3 void\cf1  InterceptedMethod()\par ??                \{\par ??                    \cf5 Recorder\cf1 .Records.Add(\cf6 "In Method"\cf1 );\par ??                \}\par ??\par ??                \cf3 public\cf1  \cf3 void\cf1  ThrowsException()\par ??                \{\par ??                    \cf3 throw\cf1  \cf3 new\cf1  \cf5 Exception\cf1 ();\par ??                \}\par ??            \}}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;interface&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;ISpy&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; InterceptedMethod();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; ThrowsException();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;internal&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;sealed&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt; &lt;span style="color: yellow;"&gt;SpyInterfaceAttributes&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;ISpy&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                [&lt;span style="color: yellow;"&gt;InterfaceIntercept&lt;/span&gt;(&lt;span style="color: rgb(255, 128, 0);"&gt;typeof&lt;/span&gt;(&lt;span style="color: yellow;"&gt;RecordingHandler&lt;/span&gt;))]&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; InterceptedMethod()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                    &lt;span style="color: yellow;"&gt;Recorder&lt;/span&gt;.Records.Add(&lt;span style="color: lime;"&gt;"In Method"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; ThrowsException()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                    &lt;span style="color: rgb(255, 128, 0);"&gt;throw&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt; &lt;span style="color: yellow;"&gt;Exception&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            }&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
What this class allows us to do is to register an intercepting interface handler, in this case the RecordingHandler.  What we intend to have done is that we record a message once we're in the method.  Then our interceptor can put in calls before and after our method call just to prove a point.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green128\blue0;\red40\green40\blue40;\red255\green255\blue255;\red255\green255\blue0;\red43\green145\blue175;\red0\green255\blue0;}??\fs16 \cf1\cb2\highlight2 namespace\cf3  ObjectBuilder\par ??\{\par ??    \cf1 public\cf3  \cf1 class\cf3  \cf4 RecordingHandler\cf3  : \cf5 IInterceptionHandler\par ??\cf3     \{\par ??        \cf1 readonly\cf3  \cf1 string\cf3  message;\par ??\par ??        \cf1 public\cf3  RecordingHandler()\par ??        \{\par ??            message = \cf6 ""\cf3 ;\par ??        \}\par ??\par ??        \cf1 public\cf3  RecordingHandler(\cf1 string\cf3  message)\par ??        \{\par ??            \cf1 this\cf3 .message = \cf1 string\cf3 .Format(\cf6 " (\{0\})"\cf3 , message);\par ??        \}\par ??\par ??        \cf1 public\cf3  \cf5 IMethodReturn\cf3  Invoke(\cf5 IMethodInvocation\cf3  call,\par ??                                    \cf5 GetNextHandlerDelegate\cf3  getNext)\par ??        \{\par ??            \cf4 Recorder\cf3 .Records.Add(\cf6 "Before Method"\cf3  + message);\par ??            \cf5 IMethodReturn\cf3  result = getNext().Invoke(call, getNext);\par ??            \cf4 Recorder\cf3 .Records.Add(\cf6 "After Method"\cf3  + message);\par ??            \cf1 return\cf3  result;\par ??        \}\par ??    \}\par ??\}}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;namespace&lt;/span&gt; ObjectBuilder&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt; &lt;span style="color: yellow;"&gt;RecordingHandler&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;IInterceptionHandler&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;readonly&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;string&lt;/span&gt; message;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; RecordingHandler()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            message = &lt;span style="color: lime;"&gt;""&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; RecordingHandler(&lt;span style="color: rgb(255, 128, 0);"&gt;string&lt;/span&gt; message)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;this&lt;/span&gt;.message = &lt;span style="color: rgb(255, 128, 0);"&gt;string&lt;/span&gt;.Format(&lt;span style="color: lime;"&gt;" ({0})"&lt;/span&gt;, message);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IMethodReturn&lt;/span&gt; Invoke(&lt;span style="color: rgb(43, 145, 175);"&gt;IMethodInvocation&lt;/span&gt; call,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                                    &lt;span style="color: rgb(43, 145, 175);"&gt;GetNextHandlerDelegate&lt;/span&gt; getNext)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: yellow;"&gt;Recorder&lt;/span&gt;.Records.Add(&lt;span style="color: lime;"&gt;"Before Method"&lt;/span&gt; + message);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(43, 145, 175);"&gt;IMethodReturn&lt;/span&gt; result = getNext().Invoke(call, getNext);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: yellow;"&gt;Recorder&lt;/span&gt;.Records.Add(&lt;span style="color: lime;"&gt;"After Method"&lt;/span&gt; + message);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;return&lt;/span&gt; result;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
This IInterceptionHandler interface handles the basic interception tasks of doing some before and after work on the given method.  Here it is doing nothing special but recording a message before and after intercepting the method call.  I encourage you to dig through this a bit more and understand where it is coming from, because it's good stuff and heck, you might learn some IL emitting as well.  It's a shame I didn't see some of this IP get rolled into Unity, but we can hope some of it does.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt; Interception in Castle Windsor&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Like above with ObjectBuilder2, Castle Windsor has a lightweight interception capability as well.  I covered this in a previous post, but I'll elaborate on it further.  There isn't much on Windsor interception documentation, but you can read about that &lt;a href="http://www.castleproject.org/container/documentation/v1rc3/usersguide/interceptors.html"&gt;here&lt;/a&gt;.  To take advantage of method interception, simply implement the IInterceptor interface which is marked below.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;\red43\green145\blue175;}??\fs16 \cf1\cb2\highlight2     \cf3 public\cf1  \cf3 interface\cf1  \cf4 IInterceptor\par ??\cf1     \{\par ??        \cf3 void\cf1  Intercept(\cf4 IInvocation\cf1  invocation);\par ??    \}}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;interface&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IInterceptor&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; Intercept(&lt;span style="color: rgb(43, 145, 175);"&gt;IInvocation&lt;/span&gt; invocation);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
And then we can implement a simple logger interceptor which goes ahead and logs the before and after information as well as anything else you might want to log that comes from the method signature such as arguments, method name, targets, etc.  Here, I'm doing nothing special at all, but play around with the IInvocation interface to find out what you can do.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green128\blue0;\red40\green40\blue40;\red255\green255\blue255;\red255\green255\blue0;\red43\green145\blue175;\red0\green255\blue0;}??\fs16 \cf1\cb2\highlight2 using\cf3  Castle.Core.Interceptor;\par ??\par ??\cf1 namespace\cf3  CastleSamples\par ??\{\par ??    \cf1 public\cf3  \cf1 class\cf3  \cf4 LoggingInterceptor\cf3  : \cf5 IInterceptor\par ??\cf3     \{\par ??        \cf1 private\cf3  \cf4 DebugLogger\cf3  logger = \cf1 new\cf3  \cf4 DebugLogger\cf3 ();\par ??\par ??        \cf1 public\cf3  \cf1 void\cf3  Intercept(\cf5 IInvocation\cf3  invocation)\par ??        \{\par ??            logger.Log(\cf6 "Before Method"\cf3 );\par ??            invocation.Proceed();\par ??            logger.Log(\cf6 "After Method"\cf3 );\par ??        \}\par ??    \}\par ??\}\par ??}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;using&lt;/span&gt; Castle.Core.Interceptor;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;namespace&lt;/span&gt; CastleSamples&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt; &lt;span style="color: yellow;"&gt;LoggingInterceptor&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;IInterceptor&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;private&lt;/span&gt; &lt;span style="color: yellow;"&gt;DebugLogger&lt;/span&gt; logger = &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt; &lt;span style="color: yellow;"&gt;DebugLogger&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; Intercept(&lt;span style="color: rgb(43, 145, 175);"&gt;IInvocation&lt;/span&gt; invocation)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            logger.Log(&lt;span style="color: lime;"&gt;"Before Method"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            invocation.Proceed();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            logger.Log(&lt;span style="color: lime;"&gt;"After Method"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
Like I said above, I am doing nothing special here other than to show that I can log before and after calls, and I have the option of doing more whether I want to proceed with the method call or not.  I can easily register the interceptor either through code, through Binsor or through the XML muck.  An post of mine goes through that &lt;a href="http://geekswithblogs.net/Podwysocki/archive/2008/01/23/118842.aspx"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
To me, these lightweight interceptors are nice, but I don't get much value out of them just yet outside of logging and such.  Ayende has similar thoughts about the uses of AOP in Windsor &lt;a href="http://www.ayende.com/Blog/archive/2007/03/13/Recommended-approaches-to-AOP-with-Windsor.aspx"&gt;here&lt;/a&gt;.  He also covers doing a Policy Injection Application Block style approach in Windsor as well &lt;a href="http://www.ayende.com/Blog/archive/2007/03/07/Building-the-Policy-Injection-in-40-Minutes-with-Windsor.aspx"&gt;here&lt;/a&gt;.  &lt;br /&gt;
&lt;br /&gt;
One off the topics discussed at DC ALT.NET was about using Windsor Interception to implement the Unit of Work pattern to implement undo logic for a WPF application.  It was a pretty interesting approach to the issue and I'll definitely have to dig into that a little deeper as well.  I'm hoping &lt;a href="http://blogs.ent0.com/blogs/philmcmillan/"&gt;Phil McMillan&lt;/a&gt; starts blogging more anyways...  But, obviously there are uses of interception and AOP in the enterprise and I'll get to that in the next post in the series.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt; Conclusion&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, interception is an interesting topic that needs to be explored a bit more before I'd call this subject done.   After all, I haven't touch most other containers, and I definitely want to get into AOP and Spring.NET as it is a topic I'd like to dive a little deeper into as well as AOP in the Enterprise model.  Things that make the .NET rramework bend in all sorts of ways is always a worth cause.  Anyhow, I hope this dive again into the subject is useful and any feedback is appreciated.  Until next time...
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://geekswithblogs.net/Podwysocki/archive/2008/03/26/120764.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://geekswithblogs.net/Podwysocki/archive/2008/03/26/120764.aspx" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=120764"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=120764" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Podwysocki/aggbug/120764.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Matthew Podwysocki</dc:creator>
            <guid>http://geekswithblogs.net/Podwysocki/archive/2008/03/26/120764.aspx</guid>
            <pubDate>Wed, 26 Mar 2008 05:33:03 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Podwysocki/comments/120764.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Podwysocki/archive/2008/03/26/120764.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Podwysocki/comments/commentRss/120764.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Podwysocki/services/trackbacks/120764.aspx</trackback:ping>
        </item>
        <item>
            <title>IoC Container, Unity and Breaking Changes Galore</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/03/07/120336.aspx</link>
            <description>&lt;span style="font-weight: bold;"&gt;Update: &lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/03/25/ioc-and-unity-the-basics-and-interception.aspx"&gt;IoC and Unity - The Basics and Interception&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As &lt;a href="http://blogs.msdn.com/agile/"&gt;Grigori Melnik&lt;/a&gt; noted on my blog previously as well as his &lt;a href="http://blogs.msdn.com/agile/archive/2008/03/04/unity-project-heartbeat.aspx"&gt;own&lt;/a&gt;, there was a brand new drop of the &lt;a href="http://www.codeplex.com/unity"&gt;Unity Application Block&lt;/a&gt; as of &lt;a href="http://www.codeplex.com/unity/Release/ProjectReleases.aspx?ReleaseId=11319"&gt;March 4th&lt;/a&gt;.  This by far was a huge update with a lot of breaking changes.  That teaches me to use a CTP of any product and blog about it actively as it compares to other &lt;a href="http://en.wikipedia.org/wiki/Inversion_of_control"&gt;Inversion of Control (IoC)&lt;/a&gt; containers.  Glad I didn't do a lot on ASP.NET MVC just yet but I have a few good projects going on the side with that now.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Where I've Been Before&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As noted here before, I've been spending some time actively comparing the Unity Application Block to other IoC containers and what each offers.  Let's get caught up to my previous posts:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://geekswithblogs.net/Podwysocki/archive/2008/02/18/119744.aspx"&gt;IoC and the Unity Application Block&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://geekswithblogs.net/Podwysocki/archive/2008/02/22/119911.aspx"&gt;IoC and the Unity Application Block - Going Deeper&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://geekswithblogs.net/Podwysocki/archive/2008/02/26/120002.aspx"&gt;IoC and the Unity Application Block Once Again&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://geekswithblogs.net/Podwysocki/archive/2008/03/04/120185.aspx"&gt;IoC Containers, Unity and ObjectBuilder2 - The Saga Continues&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
I'm probably going to change the code on each one just so that you all don't get angry about code from me not working, so stay tuned, it will get done.  But, keep in mind, it is still CTP, and I'd rather concentrate on the concepts as well.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;What's Changed&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As you may notice if you did any of the code snippets I published, they sure as heck don't build anymore.  So, let's enumerate the changes made so far:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;UnityContainer method Register&amp;lt;TFrom, TTo&amp;gt;() becomes RegisterType&amp;lt;TFrom, TTo&amp;gt;()&lt;/li&gt;
    &lt;li&gt;UnityContainer method Get&amp;lt;T&amp;gt;() becomes Resolve&amp;lt;T&amp;gt;&lt;/li&gt;
    &lt;li&gt;UnityContainer method SetSingleton&amp;lt;T&amp;gt; removed&lt;/li&gt;
    &lt;li&gt;UnityContainer method RegisterType&amp;lt;TFrom, TTo&amp;gt; accepts a LifetimeManager to create Singletons&lt;/li&gt;
    &lt;li&gt;Added ContainerControlledLifetimeManager and ExternallyControlledLifetimeManager&lt;/li&gt;
    &lt;li&gt;Removed DependencyAttribute NotPresentBehavior property and enum&lt;/li&gt;
    &lt;li&gt;Added UnityContainer CreateChildContainer method to create child sandboxes&lt;/li&gt;
    &lt;li&gt;Reversed the parameters for UnityContainer method RegisterInstance&amp;lt;T&amp;gt;(value, key) to RegisterInstance&amp;lt;T&amp;gt;(key, value)&lt;/li&gt;
&lt;/ul&gt;
As you can see, some of these changes can be seen as quite annoying especially if I were to have a method such as the following and I can't find the error until I sit and read the code through and through:&lt;br /&gt;
&lt;br /&gt;
Old:&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red43\green145\blue175;\red255\green128\blue0;\red255\green255\blue0;\red0\green255\blue0;}??\fs16 \cf1\cb2\highlight2             \cf3 IUnityContainer\cf1  container = \cf4 new\cf1  \cf5 UnityContainer\cf1 ();\par ??            container\par ??                .RegisterType&amp;lt;\cf3 ILogger\cf1 , \cf5 ConsoleLogger\cf1 &amp;gt;(\cf4 new\cf1  \cf5 ContainerControlledLifetimeManager\cf1 ())\par ??                .RegisterInstance&amp;lt;\cf4 string\cf1 &amp;gt;(\cf6 "defaultFromAddress"\cf1 , \cf6 "administrator@example.com"\cf1 );}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;IUnityContainer&lt;/span&gt; container = &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt; &lt;span style="color: yellow;"&gt;UnityContainer&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;container&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    .RegisterType&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;ILogger&lt;/span&gt;, &lt;span style="color: yellow;"&gt;ConsoleLogger&lt;/span&gt;&amp;gt;(&lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt; &lt;span style="color: yellow;"&gt;ContainerControlledLifetimeManager&lt;/span&gt;())&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    .RegisterInstance&amp;lt;&lt;span style="color: rgb(255, 128, 0);"&gt;string&lt;/span&gt;&amp;gt;(&lt;span style="color: lime;"&gt;"administrator@example.com"&lt;span style="color: rgb(255, 255, 255);"&gt;,&lt;/span&gt; &lt;/span&gt;&lt;span style="color: lime;"&gt;"defaultFromAddress"&lt;/span&gt;&lt;span style="color: lime;"&gt;&lt;/span&gt;);&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
And sure enough, it blew up due to the fact that it seemed just fine because it was RegisterInstance&amp;lt;string&amp;gt;(string, string) and instead I had to change it to this to get it to work.&lt;br /&gt;
&lt;br /&gt;
New:&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red43\green145\blue175;\red255\green128\blue0;\red255\green255\blue0;\red0\green255\blue0;}??\fs16 \cf1\cb2\highlight2             \cf3 IUnityContainer\cf1  container = \cf4 new\cf1  \cf5 UnityContainer\cf1 ();\par ??            container\par ??                .RegisterType&amp;lt;\cf3 ILogger\cf1 , \cf5 ConsoleLogger\cf1 &amp;gt;(\cf4 new\cf1  \cf5 ContainerControlledLifetimeManager\cf1 ())\par ??                .RegisterInstance&amp;lt;\cf4 string\cf1 &amp;gt;(\cf6 "defaultFromAddress"\cf1 , \cf6 "administrator@example.com"\cf1 );}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color