<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" 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:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Joshua Flanagan - structuremap</title>
    <link>http://flimflan.com/blog/</link>
    <description>A .NET Software Developer</description>
    <language>en-us</language>
    <copyright>josh</copyright>
    <lastBuildDate>Fri, 25 Jul 2008 14:11:05 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.1.8209.14743</generator>
    <managingEditor>josh@flimflan.com</managingEditor>
    <webMaster>josh@flimflan.com</webMaster>
    <item>
      <trackback:ping>http://flimflan.com/blog/Trackback.aspx?guid=1f06b8f7-1fb7-4cde-899c-acd051b3b594</trackback:ping>
      <pingback:server>http://flimflan.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://flimflan.com/blog/PermaLink,guid,1f06b8f7-1fb7-4cde-899c-acd051b3b594.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://flimflan.com/blog/CommentView,guid,1f06b8f7-1fb7-4cde-899c-acd051b3b594.aspx</wfw:comment>
      <wfw:commentRss>http://flimflan.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=1f06b8f7-1fb7-4cde-899c-acd051b3b594</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In a comment on <a href="http://devlicio.us/blogs/derik_whittaker/" target="_blank">Derik
Whittaker</a>'s post about <a href="http://devlicio.us/blogs/derik_whittaker/archive/2008/07/24/using-your-app-config-web-config-to-store-your-structuremap-settings.aspx" target="_blank">using
app.config with StructureMap</a>, Brian Johnston asks for a simple "hello world" example.
I figured I could re-create the app that I used when I was first learning <a href="http://structuremap.sourceforge.net/" target="_blank">StructureMap</a>.
This is a very simple demonstration of how to make an application use StructureMap.
It does not get into the whys and whens for different scenarios. It is simply a piece
of code that will let you see StructureMap "work" so that you can play with it. For
more introductory details, I would highly recommend reading <a href="http://www.lostechies.com/blogs/chad_myers/" target="_blank">Chad
Myers</a>' posts that cover <a href="http://www.lostechies.com/blogs/chad_myers/archive/2008/07/15/structuremap-basic-scenario-usage.aspx" target="_blank">Basic</a> and <a href="http://www.lostechies.com/blogs/chad_myers/archive/2008/07/17/structuremap-medium-level-usage-scenarios.aspx" target="_blank">Medium-level
usage scenarios</a> for StructureMap.
</p>
        <h2>Create the app
</h2>
        <ol>
          <li>
Open Visual Studio 
</li>
          <li>
Go to File | New | Console Application (hopefully you have Tools | Options | Projects
and Solutions | "Save new projects when created" UNCHECKED so you aren't forced to
choose a path for this throwaway code) 
</li>
          <li>
Add a reference to StructureMap.dll (agonize over how slow the Add Reference dialog
box is to open because it needs to populate the list on the .NET tab which will go
unused when we switch to the Browse tab) 
</li>
          <li>
Replace the contents of Program.cs with the code at the bottom of this post 
</li>
          <li>
Run the application to see the English greeting.</li>
        </ol>
        <h2>Notes
</h2>
        <ul>
          <li>
The call to ObjectFactory.GetInstance in the Main method demonstrates how you get
an object from StructureMap. Notice that it only specifies the interface for the type
you'd like to retrieve so the caller is decoupled from the actual implementation that
is used.</li>
          <li>
The ConfigureDependencies method is where I tell StructureMap which concrete implementations
I would like to use for my interfaces. You can accomplish this same goal by decorating
your interfaces and classes with attributes, or by using a configuration file.</li>
          <li>
Aside from the two bullet items above in the Program class, none of the rest of the
code has any reference to or knowledge of StructureMap.</li>
          <li>
Notice that I only ever ask for an IAppEngine. I never had to explicitly ask for an
IGreeter or IOutputDisplay. StructureMap was smart enough to recognize these dependencies
of AppEngine and injected them automatically. 
</li>
          <li>
Change the second line in ConfigureDependencies so that TheDefaultIsConcreteType&lt;FrenchGreeter&gt;
and run the application again. Notice that you now see the French greeting. You have
changed the implementation that is used by AppEngine, without changing any of the
application code (if you agree that the Program class is just your launching point,
and not really part of the application logic). If you were using a config file to
configure StructureMap, you wouldn't have had to change any code at all to see the
different behavior.</li>
        </ul>
        <h2>Code
</h2>
        <p>
          <span style="font-weight:bold">Update:</span> I've created a <a href="http://gist.github.com/397213">gist</a> that
shows the original example, but using the cleaner syntax introduced in more recent
versions of StructureMap.
</p>
        <script src="http://gist.github.com/397213.js?file=hello_structuremap.cs">
        </script>
        <h3>The original code from this post that used older StructureMap syntax:
</h3>
        <div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:68dc39b1-3528-4de0-ac36-a54d753ab1f6" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
          <pre style="background-color:White;;overflow: auto;">
            <div>
              <!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
              <span style="color: #0000FF;">using</span>
              <span style="color: #000000;"> System; </span>
              <span style="color: #0000FF;">using</span>
              <span style="color: #000000;"> StructureMap; </span>
              <span style="color: #0000FF;">namespace</span>
              <span style="color: #000000;"> ConsoleApplication1
{ </span>
              <span style="color: #0000FF;">class</span>
              <span style="color: #000000;"> Program
{ </span>
              <span style="color: #0000FF;">private</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">static</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">void</span>
              <span style="color: #000000;"> Main(</span>
              <span style="color: #0000FF;">string</span>
              <span style="color: #000000;">[]
args) { ConfigureDependencies(); IAppEngine appEngine </span>
              <span style="color: #000000;">=</span>
              <span style="color: #000000;"> ObjectFactory.GetInstance</span>
              <span style="color: #000000;">&lt;</span>
              <span style="color: #000000;">IAppEngine</span>
              <span style="color: #000000;">&gt;</span>
              <span style="color: #000000;">();
appEngine.Run(); } </span>
              <span style="color: #0000FF;">private</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">static</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">void</span>
              <span style="color: #000000;"> ConfigureDependencies()
{ StructureMapConfiguration.ForRequestedType</span>
              <span style="color: #000000;">&lt;</span>
              <span style="color: #000000;">IAppEngine</span>
              <span style="color: #000000;">&gt;</span>
              <span style="color: #000000;">().TheDefaultIsConcreteType</span>
              <span style="color: #000000;">&lt;</span>
              <span style="color: #000000;">AppEngine</span>
              <span style="color: #000000;">&gt;</span>
              <span style="color: #000000;">();
StructureMapConfiguration.ForRequestedType</span>
              <span style="color: #000000;">&lt;</span>
              <span style="color: #000000;">IGreeter</span>
              <span style="color: #000000;">&gt;</span>
              <span style="color: #000000;">().TheDefaultIsConcreteType</span>
              <span style="color: #000000;">&lt;</span>
              <span style="color: #000000;">EnglishGreeter</span>
              <span style="color: #000000;">&gt;</span>
              <span style="color: #000000;">();
StructureMapConfiguration.ForRequestedType</span>
              <span style="color: #000000;">&lt;</span>
              <span style="color: #000000;">IOutputDisplay</span>
              <span style="color: #000000;">&gt;</span>
              <span style="color: #000000;">().TheDefaultIsConcreteType</span>
              <span style="color: #000000;">&lt;</span>
              <span style="color: #000000;">ConsoleOutputDisplay</span>
              <span style="color: #000000;">&gt;</span>
              <span style="color: #000000;">();
} } </span>
              <span style="color: #0000FF;">public</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">class</span>
              <span style="color: #000000;"> AppEngine
: IAppEngine { </span>
              <span style="color: #0000FF;">private</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">readonly</span>
              <span style="color: #000000;"> IGreeter
greeter; </span>
              <span style="color: #0000FF;">private</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">readonly</span>
              <span style="color: #000000;"> IOutputDisplay
outputDisplay; </span>
              <span style="color: #0000FF;">public</span>
              <span style="color: #000000;"> AppEngine(IGreeter
greeter, IOutputDisplay outputDisplay) { </span>
              <span style="color: #0000FF;">this</span>
              <span style="color: #000000;">.greeter </span>
              <span style="color: #000000;">=</span>
              <span style="color: #000000;"> greeter; </span>
              <span style="color: #0000FF;">this</span>
              <span style="color: #000000;">.outputDisplay </span>
              <span style="color: #000000;">=</span>
              <span style="color: #000000;"> outputDisplay;
} </span>
              <span style="color: #0000FF;">public</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">void</span>
              <span style="color: #000000;"> Run()
{ outputDisplay.Show(greeter.GetGreeting()); } } </span>
              <span style="color: #0000FF;">public</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">interface</span>
              <span style="color: #000000;"> IAppEngine
{ </span>
              <span style="color: #0000FF;">void</span>
              <span style="color: #000000;"> Run();
} </span>
              <span style="color: #0000FF;">public</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">interface</span>
              <span style="color: #000000;"> IGreeter
{ </span>
              <span style="color: #0000FF;">string</span>
              <span style="color: #000000;"> GetGreeting();
} </span>
              <span style="color: #0000FF;">public</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">class</span>
              <span style="color: #000000;"> EnglishGreeter
: IGreeter { </span>
              <span style="color: #0000FF;">public</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">string</span>
              <span style="color: #000000;"> GetGreeting()
{ </span>
              <span style="color: #0000FF;">return</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #800000;">"</span>
              <span style="color: #800000;">Hello</span>
              <span style="color: #800000;">"</span>
              <span style="color: #000000;">;
} } </span>
              <span style="color: #0000FF;">public</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">class</span>
              <span style="color: #000000;"> FrenchGreeter
: IGreeter { </span>
              <span style="color: #0000FF;">public</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">string</span>
              <span style="color: #000000;"> GetGreeting()
{ </span>
              <span style="color: #0000FF;">return</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #800000;">"</span>
              <span style="color: #800000;">Bonjour</span>
              <span style="color: #800000;">"</span>
              <span style="color: #000000;">;
} } </span>
              <span style="color: #0000FF;">public</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">interface</span>
              <span style="color: #000000;"> IOutputDisplay
{ </span>
              <span style="color: #0000FF;">void</span>
              <span style="color: #000000;"> Show(</span>
              <span style="color: #0000FF;">string</span>
              <span style="color: #000000;"> message);
} </span>
              <span style="color: #0000FF;">public</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">class</span>
              <span style="color: #000000;"> ConsoleOutputDisplay
: IOutputDisplay { </span>
              <span style="color: #0000FF;">public</span>
              <span style="color: #000000;">
              </span>
              <span style="color: #0000FF;">void</span>
              <span style="color: #000000;"> Show(</span>
              <span style="color: #0000FF;">string</span>
              <span style="color: #000000;"> message)
{ Console.WriteLine(message); } } }</span>
            </div>
          </pre>
          <!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com -->
        </div>
        <img width="0" height="0" src="http://flimflan.com/blog/aggbug.ashx?id=1f06b8f7-1fb7-4cde-899c-acd051b3b594" />
      </body>
      <title>Hello StructureMap</title>
      <guid isPermaLink="false">http://flimflan.com/blog/PermaLink,guid,1f06b8f7-1fb7-4cde-899c-acd051b3b594.aspx</guid>
      <link>http://flimflan.com/blog/HelloStructureMap.aspx</link>
      <pubDate>Fri, 25 Jul 2008 14:11:05 GMT</pubDate>
      <description>&lt;p&gt;
In a comment on &lt;a href="http://devlicio.us/blogs/derik_whittaker/" target="_blank"&gt;Derik
Whittaker&lt;/a&gt;'s post about &lt;a href="http://devlicio.us/blogs/derik_whittaker/archive/2008/07/24/using-your-app-config-web-config-to-store-your-structuremap-settings.aspx" target="_blank"&gt;using
app.config with StructureMap&lt;/a&gt;, Brian Johnston asks for a simple "hello world" example.
I figured I could re-create the app that I used when I was first learning &lt;a href="http://structuremap.sourceforge.net/" target="_blank"&gt;StructureMap&lt;/a&gt;.
This is a very simple demonstration of how to make an application use StructureMap.
It does not get into the whys and whens for different scenarios. It is simply a piece
of code that will let you see StructureMap "work" so that you can play with it. For
more introductory details, I would highly recommend reading &lt;a href="http://www.lostechies.com/blogs/chad_myers/" target="_blank"&gt;Chad
Myers&lt;/a&gt;' posts that cover &lt;a href="http://www.lostechies.com/blogs/chad_myers/archive/2008/07/15/structuremap-basic-scenario-usage.aspx" target="_blank"&gt;Basic&lt;/a&gt; and &lt;a href="http://www.lostechies.com/blogs/chad_myers/archive/2008/07/17/structuremap-medium-level-usage-scenarios.aspx" target="_blank"&gt;Medium-level
usage scenarios&lt;/a&gt; for StructureMap.
&lt;/p&gt;
&lt;h2&gt;Create the app
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
Open Visual Studio 
&lt;li&gt;
Go to File | New | Console Application (hopefully you have Tools | Options | Projects
and Solutions | "Save new projects when created" UNCHECKED so you aren't forced to
choose a path for this throwaway code) 
&lt;li&gt;
Add a reference to StructureMap.dll (agonize over how slow the Add Reference dialog
box is to open because it needs to populate the list on the .NET tab which will go
unused when we switch to the Browse tab) 
&lt;li&gt;
Replace the contents of Program.cs with the code at the bottom of this post 
&lt;li&gt;
Run the application to see the English greeting.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Notes
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
The call to ObjectFactory.GetInstance in the Main method demonstrates how you get
an object from StructureMap. Notice that it only specifies the interface for the type
you'd like to retrieve so the caller is decoupled from the actual implementation that
is used.&lt;/li&gt;
&lt;li&gt;
The ConfigureDependencies method is where I tell StructureMap which concrete implementations
I would like to use for my interfaces. You can accomplish this same goal by decorating
your interfaces and classes with attributes, or by using a configuration file.&lt;/li&gt;
&lt;li&gt;
Aside from the two bullet items above in the Program class, none of the rest of the
code has any reference to or knowledge of StructureMap.&lt;/li&gt;
&lt;li&gt;
Notice that I only ever ask for an IAppEngine. I never had to explicitly ask for an
IGreeter or IOutputDisplay. StructureMap was smart enough to recognize these dependencies
of AppEngine and injected them automatically. 
&lt;/li&gt;
&lt;li&gt;
Change the second line in ConfigureDependencies so that TheDefaultIsConcreteType&amp;lt;FrenchGreeter&amp;gt;
and run the application again. Notice that you now see the French greeting. You have
changed the implementation that is used by AppEngine, without changing any of the
application code (if you agree that the Program class is just your launching point,
and not really part of the application logic). If you were using a config file to
configure StructureMap, you wouldn't have had to change any code at all to see the
different behavior.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Code
&lt;/h2&gt;
&lt;p&gt;
&lt;span style="font-weight:bold"&gt;Update:&lt;/span&gt; I've created a &lt;a href="http://gist.github.com/397213"&gt;gist&lt;/a&gt; that
shows the original example, but using the cleaner syntax introduced in more recent
versions of StructureMap.
&lt;/p&gt;
&lt;script src="http://gist.github.com/397213.js?file=hello_structuremap.cs"&gt;&lt;/script&gt;
&lt;h3&gt;The original code from this post that used older StructureMap syntax:
&lt;/h3&gt;
&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:68dc39b1-3528-4de0-ac36-a54d753ab1f6" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;
&lt;div&gt;
&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; StructureMap; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;namespace&lt;/span&gt;&lt;span style="color: #000000;"&gt; ConsoleApplication1
{ &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; Program
{ &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; Main(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;[]
args) { ConfigureDependencies(); IAppEngine appEngine &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; ObjectFactory.GetInstance&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;IAppEngine&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;();
appEngine.Run(); } &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; ConfigureDependencies()
{ StructureMapConfiguration.ForRequestedType&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;IAppEngine&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;().TheDefaultIsConcreteType&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;AppEngine&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;();
StructureMapConfiguration.ForRequestedType&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;IGreeter&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;().TheDefaultIsConcreteType&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;EnglishGreeter&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;();
StructureMapConfiguration.ForRequestedType&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;IOutputDisplay&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;().TheDefaultIsConcreteType&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;ConsoleOutputDisplay&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;();
} } &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; AppEngine
: IAppEngine { &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;readonly&lt;/span&gt;&lt;span style="color: #000000;"&gt; IGreeter
greeter; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;readonly&lt;/span&gt;&lt;span style="color: #000000;"&gt; IOutputDisplay
outputDisplay; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; AppEngine(IGreeter
greeter, IOutputDisplay outputDisplay) { &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.greeter &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; greeter; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.outputDisplay &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; outputDisplay;
} &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; Run()
{ outputDisplay.Show(greeter.GetGreeting()); } } &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;interface&lt;/span&gt;&lt;span style="color: #000000;"&gt; IAppEngine
{ &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; Run();
} &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;interface&lt;/span&gt;&lt;span style="color: #000000;"&gt; IGreeter
{ &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; GetGreeting();
} &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; EnglishGreeter
: IGreeter { &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; GetGreeting()
{ &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Hello&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;;
} } &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; FrenchGreeter
: IGreeter { &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; GetGreeting()
{ &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Bonjour&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;;
} } &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;interface&lt;/span&gt;&lt;span style="color: #000000;"&gt; IOutputDisplay
{ &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; Show(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; message);
} &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; ConsoleOutputDisplay
: IOutputDisplay { &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; Show(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; message)
{ Console.WriteLine(message); } } }&lt;/span&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://flimflan.com/blog/aggbug.ashx?id=1f06b8f7-1fb7-4cde-899c-acd051b3b594" /&gt;</description>
      <comments>http://flimflan.com/blog/CommentView,guid,1f06b8f7-1fb7-4cde-899c-acd051b3b594.aspx</comments>
      <category>structuremap</category>
    </item>
  </channel>
</rss>