<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://devlicio.us/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Derik Whittaker : StructureMap, Agile</title><link>http://devlicio.us/blogs/derik_whittaker/archive/tags/StructureMap/Agile/default.aspx</link><description>Tags: StructureMap, Agile</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>StructureMap and Loaded Plugins Gotcha</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2008/12/18/structuremap-and-loaded-plugins-gotcha.aspx</link><pubDate>Fri, 19 Dec 2008 02:33:14 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:43448</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=43448</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=43448</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2008/12/18/structuremap-and-loaded-plugins-gotcha.aspx#comments</comments><description>&lt;p&gt;One of the really great things about the latest release of StructureMap is that I do not need to register objects by default if they follow a standard convention (i.e. if I want to register a controller called ‘AuthorController’ and accessed via ‘AuthorController’ I do not need to do anything, SM is smart enough to map this for me).&amp;#160; However, as great as this is, there is one slight issue (may be a bug, do not know need to follow up with Jeremy).&lt;/p&gt;  &lt;p&gt;In the Dimecasts codebase I put the logic to register routes for each controller into each controller.&amp;#160; I then at startup time I loop though all the controllers and register each route.&lt;/p&gt;  &lt;p&gt;The code below is the logic I do for performing this registration&lt;/p&gt;  &lt;pre class="c-sharp" name="code"&gt;	
	var controllerInstances = ObjectFactory.Model.PluginTypes.Where(x =&amp;gt; typeof(BaseController).IsAssignableFrom(x.PluginType));

	foreach (var controllerInstance in controllerInstances) 
	{ 

	var instance = (BaseController)ObjectFactory.GetInstance(controllerInstance.PluginType); 

	instance.RegisterRoutes(RouteTable.Routes); 

	}&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;All of this works and works well but when i added a new controller to the application and did not manually register it (aka using the convention of configuration feature) I was not able to load the new controller.&amp;#160; I was a little stumped at first, but then it downed on me that since i am not pre-registering the controller with StructureMap it may not now how to find it.&amp;#160; To test this theory i simply manually registered the controller and bam, all worked.&lt;/p&gt;

&lt;p&gt;I thought I would share this incase anyone else had the same issue.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;

&lt;p&gt;[--- Remember to check out &lt;a href="http://www.dimecasts.net"&gt;www.dimecasts.net&lt;/a&gt; ---]&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=43448" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Agile/default.aspx">Agile</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/.Net/default.aspx">.Net</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/StructureMap/default.aspx">StructureMap</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/ASP.Net+MVC/default.aspx">ASP.Net MVC</category></item><item><title>Using the RhinoAutoMocker that is part of StructureMap 2.5</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2008/10/05/using-the-rhinoautomocker-that-is-part-of-structuremap-2-5.aspx</link><pubDate>Sun, 05 Oct 2008 18:58:25 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:42580</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>10</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=42580</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=42580</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2008/10/05/using-the-rhinoautomocker-that-is-part-of-structuremap-2-5.aspx#comments</comments><description>&lt;p&gt;One of the new features that is part of the next release of &lt;a href="http://structuremap.sourceforge.net/"&gt;StructureMap&lt;/a&gt; 2.5 is a AutoMocking Container.&amp;nbsp; &lt;/p&gt; &lt;p&gt;What is an AutoMocking Container, well per Jacob over at Eleutian an AutoMocker is&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;AutoMockingContainer is simply a IoCContainer with a custom facility and dependency resolver that supplies a Mock (RhinoMock) for any interface that is resolved.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;My definition is a little more straight forward and uses simpler word (remember I am a simpleton :))&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;An AutoMocking container is simply a tool that will inject mock dependencies into your object for you.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;What I want to do today is show how an AutoMocking Container can reduce the amount of code/noise from your tests.&amp;nbsp;&amp;nbsp; I am going to first show a tests that simply uses RhinoMocks then that same test that uses the RhinoAutoMocker&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Test with only RhinoMocks&lt;/strong&gt;&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;[Test]
public void NoAutoMocker()
{
	var mockProvider = MockRepository.GenerateMock&amp;lt;IPersistingRulesProvider&amp;gt;();
        var mockRepository = MockRepository.GenerateMock&amp;lt;ISynchronizationRepository&amp;gt;();
        var mockPersistanceProvider = MockRepository.GenerateMock&amp;lt;IPersistanceProvider&amp;gt;();
        var mockLogger = MockRepository.GenerateMock&amp;lt;ILogger&amp;gt;();

	// Expectations
        mockProvider.Expect(x =&amp;gt; x.ExecuteRules(null)).IgnoreArguments().Throw(new Exception(&amp;quot;Do not care what this is&amp;quot;));
        mockRepository.Expect(x =&amp;gt; x.StartTransaction()).Repeat.Once();
        mockRepository.Expect(x =&amp;gt; x.RollbackTransaction()).Repeat.Once();
        mockRepository.Expect( x =&amp;gt; x.CommitTransaction() ).Repeat.Never();

	var persitingPipeline = new PersistingPipeline(mockProvider, mockPersistanceProvider, mockRepository, mockLogger);
        var result = persitingPipeline.PersistChanges(new DataSet(), 0, 0, 0);

	Assert.That( result, Is.Not.Empty );

	mockRepository.VerifyAllExpectations();
}

&lt;/pre&gt;
&lt;p&gt;This code above has a bit of noise.&amp;nbsp; Because my object has a dependency on 4 other objects i need to create mocks for each of these.&amp;nbsp; This creates more work and just adds to the test noise. 
&lt;p&gt;&lt;strong&gt;Test with the RhinoAutoMocker&lt;/strong&gt;&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;[Test]
public void WithAutoMocker()
{
	var mockPipeline = new RhinoAutoMocker&amp;lt;PersistingPipeline&amp;gt;();

	mockPipeline.Get&amp;lt;IPersistingRulesProvider&amp;gt;().Expect( x =&amp;gt; x.ExecuteRules( null ) ).IgnoreArguments().Throw( new Exception( &amp;quot;Do not care what this is&amp;quot; ) );
	mockPipeline.Get&amp;lt;ISynchronizationRepository&amp;gt;().Expect(x =&amp;gt; x.StartTransaction()).Repeat.Once();
        mockPipeline.Get&amp;lt;ISynchronizationRepository&amp;gt;().Expect(x =&amp;gt; x.RollbackTransaction()).Repeat.Once();
        mockPipeline.Get&amp;lt;ISynchronizationRepository&amp;gt;().Expect(x =&amp;gt; x.CommitTransaction()).Repeat.Never();

	var result = mockPipeline.ClassUnderTest.PersistChanges( new DataSet(), 0, 0, 0 );

	Assert.That( result, Is.Not.Empty );

}
&lt;/pre&gt;
&lt;p&gt;The code above does not require me to create mocks for each of my dependencies, the AutoMocker will do that for me.&lt;/p&gt;
&lt;p&gt;Also notice that when I need to set an expectation for a dependencies I can access it via the .Get&amp;lt;&amp;gt;() method.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;
&lt;p&gt;&lt;font color="#808080"&gt;&lt;strong&gt;[----- Remember to check out &lt;/strong&gt;&lt;strong&gt;&lt;a href="http://www.dimecasts.net"&gt;DimeCasts.Net&lt;/a&gt;&lt;/strong&gt;&lt;strong&gt; -----]&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=42580" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Development+Tools/default.aspx">Development Tools</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Agile/default.aspx">Agile</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/StructureMap/default.aspx">StructureMap</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Rhino+Mocks/default.aspx">Rhino Mocks</category></item><item><title>StructureMap 101 Error Gotcha</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2008/02/02/structuremap-101-error-gotcha.aspx</link><pubDate>Sat, 02 Feb 2008 20:48:03 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:39354</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=39354</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=39354</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2008/02/02/structuremap-101-error-gotcha.aspx#comments</comments><description>&lt;p&gt;Today I was putting together a test app for a few presentations I am doing in the coming weeks (announcements on these coming soon).&amp;#160; While doing this I kept getting a 101 exception when trying to build an object via StructureMap&amp;#39;s ObjectFactory (error information &lt;a href="http://structuremap.sourceforge.net/Troubleshooting.htm" target="_blank"&gt;here&lt;/a&gt;).&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Error message&lt;/strong&gt;    &lt;br /&gt;Assembly {AssemblyNamehere} referenced by an &amp;lt;Assembly&amp;gt; node in StructureMap.config cannot be loaded into the current AppDomain&lt;/p&gt;  &lt;p&gt;What did not make sense is that the test project had reference to the assembly that it was complaining about.&amp;#160; It turns out that I was not actually using the assembly so it did NOT copy the assembly to the bin directory during compile time.&amp;#160; Which I guess makes sense.&lt;/p&gt;  &lt;p&gt;So, after pondering what to do, I simply created a &amp;#39;hack&amp;#39; class that created an instance of an object out of the missing assembly.&amp;#160; Now it copied the .dll to the bin directly like I thought it would.&amp;#160; I can here you now, why create the &amp;#39;hack&amp;#39; class.&amp;#160; Well, simple, I was not using the assembly directly, but using it via IoC with StructureMap.&amp;#160; &lt;/p&gt;  &lt;p&gt;So, if you ever get the 101 exception from StructureMap, make sure the assembly is actually being copied to your output (bin) folder like you thought.&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=39354" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Development+Tools/default.aspx">Development Tools</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Agile/default.aspx">Agile</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/StructureMap/default.aspx">StructureMap</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/HowTo/default.aspx">HowTo</category></item><item><title>Using RhinoMocks with StructureMap to mock expected calls</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2007/07/24/using-rhinomocks-with-structuremap-to-mock-expected-calls.aspx</link><pubDate>Tue, 24 Jul 2007 14:32:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:35099</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=35099</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=35099</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2007/07/24/using-rhinomocks-with-structuremap-to-mock-expected-calls.aspx#comments</comments><description>
&lt;p class="MsoNormal"&gt;What do you do when you are writing a test for a piece of
code that calls out to an ‘out of your control’ service such as a web service
or email server?&lt;span&gt;&amp;nbsp; &lt;/span&gt;If you are like most of
us, you simply allow your test to make the call and ‘hope’ that the service is
up.&lt;span&gt;&amp;nbsp; &lt;/span&gt;However, this is really bad.&lt;span&gt;&amp;nbsp; &lt;/span&gt;Having your test make calls to a service that
is out of your control can lead to ‘spontaneous’ breakages.&lt;span&gt;&amp;nbsp; &lt;/span&gt;It also puts dependencies in your test,
another bad thing.&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;br&gt;If you are using RhinoMocks (could also use NMock, but I like
RhinoMocks) and StructureMap (could use any IoC/DI container, but I like
StructureMap) it is pretty easy and straight forward to ‘Mock’ out those
services.&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;br&gt;Quick background on this code.&lt;span&gt;&amp;nbsp; &lt;/span&gt;&lt;br&gt;This test was writing to verify that when a web service is down (&lt;span style="font-size:10pt;line-height:115%;font-family:'Courier New';"&gt;IMilesServiceContract&lt;/span&gt;) that an email (&lt;span style="font-size:10pt;line-height:115%;font-family:'Courier New';"&gt;IEmailer&lt;/span&gt;) will be sent.&lt;span&gt;&amp;nbsp; &lt;/span&gt;Because I cannot force the service to be
down, I have to ‘fake’ it out with Mocks.&lt;span&gt;&amp;nbsp;
&lt;/span&gt;And because I don’t care that the email actually gets sent I also will
fake this out.&lt;br&gt;&lt;br&gt;Below is the code that will allow you to ‘Mock’ out a web
service and them email service&lt;/p&gt;

&lt;br&gt;
&lt;textarea class="c#:nogutter" name="code" rows="30" cols="100"&gt;[Test]
public void IsHealthCheckRunning_FailureSendsEmails()
{
    MockRepository mocker = new MockRepository();

    IMilesServiceContract milesServiceContractStub = mocker.Stub&amp;lt;IMilesServiceContract&amp;gt;();
    IEmailer emailerStub = mocker.Stub&amp;lt;IEmailer&amp;gt;();

    Expect.Call(milesServiceContractStub.IsServiceAlive()).IgnoreArguments().Return(false);
    Expect.Call(emailerStub.Send()).IgnoreArguments().Return(true);

    ObjectFactory.InjectStub( typeof( IMilesServiceContract ), milesServiceContractStub );
    ObjectFactory.InjectStub( typeof( IEmailer ), emailerStub );

    IHealthMonitor monitor = ObjectFactory.GetInstance&amp;lt;IHealthMonitor&amp;gt;();
                
    // setups the mock engine
    mocker.ReplayAll();
    
    monitor.Start();

    // Because ths is on a timer, we need to wait for 5 seconds to let the procsinng take place
    System.Threading.Thread.Sleep( 5000 );

    // Make sure all our exptectations were met
    mocker.VerifyAll();
}
&lt;/textarea&gt;
&lt;br&gt;

&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;i&gt;&lt;br&gt;Code Explained&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;


&lt;p class="MsoNormal"&gt;&lt;b&gt;Generating the stubs&lt;/b&gt;&lt;br&gt;
Because I don’t want to use the actual concrete classes, I am going to create
stubs of them via RhinoMocks&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;br&gt;&lt;b&gt;Setting the
expectations&lt;/b&gt;&lt;br&gt;
Once I have the stubs created, I want to set the expectations on the methods
for each of the stubs that I want to be called.&lt;span&gt;&amp;nbsp;
&lt;/span&gt;I don’t care about the actual parameter values used, so that is why I use
the &lt;span style="font-size:10pt;line-height:115%;font-family:'Courier New';"&gt;IgnoreArguments&lt;/span&gt; method.&lt;span&gt;&amp;nbsp; &lt;/span&gt;It is here you set the default return value.&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;br&gt;&lt;b&gt;Injecting the stubs
into StructureMap&lt;/b&gt;&lt;br&gt;
In order for StructureMap to use the stubs, you need to ‘inject’ them in so
that when the next call to create the object via the ObjectFactory is called
the stubs will be returned.&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;br&gt;&lt;b&gt;ReplayAll&lt;/b&gt;&lt;br&gt;
This tells the RhinoMocks engine that all setup work is finished and to set the
mocking eninge&lt;/p&gt;

&lt;p class="MsoNormal"&gt;Few Gotcha’s to look out for&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;You must set any expectations PRIOR to using the
object/stub.&lt;span&gt;&amp;nbsp; &lt;/span&gt;Otherwise you will get an
exception.&lt;/li&gt;

&lt;li&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;It’s best/easiest to inject interfaces into
StructureMap.&lt;span&gt;&amp;nbsp; &lt;/span&gt;I have issues when ever I inject
concrete classes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&amp;nbsp;&lt;br&gt;Till next time,&amp;nbsp;&lt;/p&gt;

&lt;br&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://devlicio.us/blogs/derik_whittaker/archive/2007/07/24/using-rhinomocks-with-structuremap-to-mock-expected-calls.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://devlicio.us/blogs/derik_whittaker/archive/2007/07/24/using-rhinomocks-with-structuremap-to-mock-expected-calls.aspx" alt="kick it on DotNetKicks.com" border="0"&gt;&lt;/a&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=35099" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Development/default.aspx">Development</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Agile/default.aspx">Agile</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/.Net/default.aspx">.Net</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/StructureMap/default.aspx">StructureMap</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Rhino+Mocks/default.aspx">Rhino Mocks</category></item><item><title>StructureMap Tip: Using Concrete classes as a PluginFamily</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2007/07/23/structuremap-tip-using-concrete-classes-as-a-pluginfamily.aspx</link><pubDate>Mon, 23 Jul 2007 22:43:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:35004</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=35004</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=35004</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2007/07/23/structuremap-tip-using-concrete-classes-as-a-pluginfamily.aspx#comments</comments><description>
&lt;p&gt;Have ever wanted to use a concrete class as both the the PluginFamily and Plugable (information on StructureMap's attributes &lt;a href="http://structuremap.sourceforge.net/Attributes.htm" target="_blank"&gt;here&lt;/a&gt;)&amp;nbsp;type in &lt;a href="http://structuremap.sourceforge.net/Default.htm" target="_blank"&gt;StructureMap&lt;/a&gt;?&amp;nbsp; I know I have, just today in fact (not the first time, but thought I would post about it this time)&amp;nbsp;I needed to do just this.&amp;nbsp; Why would I want to use a concrete class as both PluginFamily and Plugable type you may ask.&amp;nbsp; Well in this case because I wanted to use &lt;a href="http://en.wikipedia.org/wiki/Dependency_injection" target="_blank"&gt;DI&lt;/a&gt; to inject my configuration class into one of my objects (via constructor injection) and did not think it was worth the effort to create an interface.&lt;/p&gt;
 
&lt;p&gt;Normally if you were use an interface as the PluginFamily and a concrete class as the Plugable, your code would look something like below.&lt;/p&gt;
 
&lt;p&gt;&lt;b&gt;Interface&lt;/b&gt;&lt;/p&gt;
 
&lt;p&gt;[PluginFamily("FamilyNameGoesHere")]&lt;br&gt;public&amp;nbsp;interface IFoo &lt;br&gt;{&lt;/p&gt;
 
&lt;p&gt;&lt;b&gt;Concrete&lt;/b&gt;&lt;/p&gt;
 
&lt;p&gt;[Pluggable("FamilyNameGoeshere")]&lt;br&gt;public class Foo : IFoo&lt;br&gt;{&lt;/p&gt;
 
&lt;p&gt;Do have your concrete class act as both you simply combine the two as such&lt;/p&gt;
 
&lt;p&gt;[PluginFamily("FamilyNameGoesHere"), Pluggable("FamilyNameGoeshere")]&lt;br&gt;public class ConcreateWithNoInterface&lt;br&gt;{&lt;/p&gt;
 
&lt;p&gt;Keep in mind, that when you do not use interfaces with DI, you are taking away a lot of the power and flexibility that DI provides you.&amp;nbsp; But there are cases from time to time where this situation comes into play.&lt;/p&gt;
 
&lt;p&gt;Till next time,&lt;/p&gt;
&lt;br&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://devlicio.us/blogs/derik_whittaker/archive/2007/07/23/structuremap-tip-using-concrete-classes-as-a-pluginfamily.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://devlicio.us/blogs/derik_whittaker/archive/2007/07/23/structuremap-tip-using-concrete-classes-as-a-pluginfamily.aspx" alt="kick it on DotNetKicks.com" border="0"&gt;&lt;/a&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=35004" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Development/default.aspx">Development</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Development+Tools/default.aspx">Development Tools</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Agile/default.aspx">Agile</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/.Net/default.aspx">.Net</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/StructureMap/default.aspx">StructureMap</category></item><item><title>What I'm Learning</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2007/06/08/what-i-m-learning.aspx</link><pubDate>Fri, 08 Jun 2007 22:18:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:28014</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=28014</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=28014</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2007/06/08/what-i-m-learning.aspx#comments</comments><description>This post is in response to Sam Gentile's post over at code better I'm Learning Rhino Mocks NHibernate StructureMap Policy Injection Blocks Log4Ne t (yea I know, what took so long. Answer, last few apps use the Logging App Block) MonoRail (about to start...(&lt;a href="http://devlicio.us/blogs/derik_whittaker/archive/2007/06/08/what-i-m-learning.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://devlicio.us/aggbug.aspx?PostID=28014" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Development/default.aspx">Development</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Development+Tools/default.aspx">Development Tools</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Agile/default.aspx">Agile</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/StructureMap/default.aspx">StructureMap</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/NHibernate/default.aspx">NHibernate</category></item></channel></rss>