<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Opgenorth.NET &#187; .NET</title>
	<atom:link href="http://www.opgenorth.net/category/programming/dot-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.opgenorth.net</link>
	<description>Mindless missives of a .NET developer from the North</description>
	<lastBuildDate>Sat, 28 Aug 2010 15:58:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>MVP in C# For 2010</title>
		<link>http://www.opgenorth.net/2010/04/05/mvp-in-c-for-2010/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mvp-in-c-for-2010</link>
		<comments>http://www.opgenorth.net/2010/04/05/mvp-in-c-for-2010/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 02:15:12 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2010/04/05/mvp-in-c-for-2010/</guid>
		<description><![CDATA[I guess I forgot to mention this:&#160; On April 1, 2010, I received an e-mail from Microsoft that my MVP in C# was renewed for the third year.&#160; This makes me a happy, because with Resharper 5 (and therefore Visual Studio 2010) and Windows Mobile 7, I’m hoping that this will be an exciting year [...]]]></description>
			<content:encoded><![CDATA[<p>I guess I forgot to mention this:&#160; On April 1, 2010, I received an e-mail from Microsoft that my <a href="https://mvp.support.microsoft.com/profile=31F1E181-79EC-4497-B792-FA8F83D34936">MVP in C#</a> was renewed for the third year.&#160; This makes me a happy, because with Resharper 5 (and therefore Visual Studio 2010) and Windows Mobile 7, I’m hoping that this will be an exciting year for the .NET crowd.&#160; </p>
<p>Well, okay, perhaps I didn’t forget.&#160; Given that it was April 1st when I got the e-mail, I like to give things a few days to settle down.&#160; I am acquainted with some mischievous pranksters who would think it was a funny April Fools joke.</p>
<p><a href="http://www.opgenorth.net/wp-content/uploads/2010/04/MVP_Horizontal_FullColor.png"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="MVP_Horizontal_FullColor" border="0" alt="MVP_Horizontal_FullColor" src="http://www.opgenorth.net/wp-content/uploads/2010/04/MVP_Horizontal_FullColor_thumb.png" width="240" height="97" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2010/04/05/mvp-in-c-for-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun in SoCal</title>
		<link>http://www.opgenorth.net/2010/03/19/fun-in-riverside/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=fun-in-riverside</link>
		<comments>http://www.opgenorth.net/2010/03/19/fun-in-riverside/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 22:43:19 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2010/03/19/fun-in-riverside/</guid>
		<description><![CDATA[Just sitting here at Legoland in Carlsbad, CA waiting for my kids to get off Coastersaurus. Just thought I&#8217;d make a mention about my presentation on SOLID to the Inland Empire .NET User Group. This is my third year in a row as their March speaker. I&#8217;m glad to say that for the third year [...]]]></description>
			<content:encoded><![CDATA[<p>Just sitting here at <a href="http://www.legoland.com/">Legoland</a> in Carlsbad, CA waiting for my kids to get off Coastersaurus. Just thought I&#8217;d make a mention about my presentation on SOLID to the <a href="http://iedotnetug.org">Inland Empire .NET User</a> Group. This is my third year in a row as their March speaker. I&#8217;m glad to say that for the third year in a row they haven&#8217;t chased me away with pitch-forks and torches. Largely based on that reason, I&#8217;ll say the presentation went well. Well, that and the fact that the concepts did seem to be understood and there were no technical glitches.</p>
<p>Thanks James and his crew for agreeing to shift from the 2nd Tuesday to the 3rd Tuesday to accommodate my travel. </p>
<p>Here is a zip of the <a href="http://www.opgenorth.net/wp-content/uploads/2010/03/InlandEmpire.zip">code and slide deck</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2010/03/19/fun-in-riverside/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Followup: TechDays 2009 in Calgary</title>
		<link>http://www.opgenorth.net/2009/11/19/techdays-2009-in-calgary-2/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=techdays-2009-in-calgary-2</link>
		<comments>http://www.opgenorth.net/2009/11/19/techdays-2009-in-calgary-2/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 03:48:09 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2009/11/19/techdays-2009-in-calgary-2/</guid>
		<description><![CDATA[Yesterday I was at TechDays 2009 in Calgary for the day (well, the morning really).  I wasn&#8217;t there as an attendee, but as a speaker.  Thanks to everybody who came out to my two talks, the first one on an Introduction to ASP.NET MVC and the second one on SOLIDifying your ASP.NET MVC Application.  There [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I was at TechDays 2009 in Calgary for the day (well, the morning really).  I wasn&#8217;t there as an attendee, but as a speaker.  Thanks to everybody who came out to my two talks, the first one on an <em>Introduction to ASP.NET MVC</em> and the second one on <em>SOLIDifying your ASP.NET MVC Application</em>.  There were a few hiccups along the way:  as usual, I fell victim to the Technical Presentation Time Dilation Syndrome (i.e. ran out of time) on both talks.  I guess I&#8217;m just to long-winded for my own good.  As well, because I was running a <a href="http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+Early+Access+Program">EAP of Resharper 5</a>, I had some Visual Studio 2008 issues &#8211; namely VS2008 would hang on me from time to time.  Note to self: maybe don&#8217;t use the bleeding edge tools in a talk.  And I really should break myself of wanting to type all the code &#8211; using snippets would really save me time.</p>
<p>Two things that suprised me:</p>
<ol>
<li>That there was still that much interest in ASP.NET MVC intro talks.  I just figured that everybody knew/knows about it.  Or maybe I just spend to much time with guys who have drunk the ASP.NET MVC Flavor Aid.  Either way, I think that there were some in the crowd that will convert from WebForms to ASP.NET MVC.</li>
<li>I asked how many people wrote unit tests or developing their software using Test Driven Development was the number of people who didn&#8217;t raise their hands.  While I didn&#8217;t expect the majority of the crowd, I did expect a lot more people than I saw.  Maybe it was a quiet crowd, and people didn&#8217;t feel like saying they wrote unit tests.  Maybe I live in a bubble, and my perception of what is actually going on in the .NET world is skewed (that is to say, perhaps writing tests is the exception rather than the rule).  It did kind of make me a bit concerned, as I truly believe that TDD does help one write better software overall.</li>
</ol>
<p>Anyway, here&#8217;s to hoping that TechDays 2010 will stop off in Edmonton.  And hopefully have a track that will focus on developer fundamentals, like TechDays had in Toronto and Vancouver.</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=2eb31f71-f855-83ff-bf64-795e87c1b4f0" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2009/11/19/techdays-2009-in-calgary-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Common Service Locator</title>
		<link>http://www.opgenorth.net/2009/03/19/common-service-locator/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=common-service-locator</link>
		<comments>http://www.opgenorth.net/2009/03/19/common-service-locator/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 00:06:00 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2009/03/19/common-service-locator/</guid>
		<description><![CDATA[One of the nice things about Dependency Injection is that it can really help write a more flexible, modular application.&#160; These days, it seems that there is no shortage of choice in the .NET community when it comes to IoC frameworks: StructureMap Castle Windsor Ninject Autofac Unity Spring.NET And probably others that I’m missing. Ironically, [...]]]></description>
			<content:encoded><![CDATA[<p>One of the nice things about <a href="http://martinfowler.com/articles/injection.html">Dependency Injection</a> is that it can really help write a more flexible, modular application.&#160; These days, it seems that there is no shortage of choice in the .NET community when it comes to IoC frameworks:</p>
<ul>
<li><a href="http://structuremap.sourceforge.net">StructureMap</a> </li>
<li><a href="http://www.castleproject.org/container/index.html">Castle Windsor</a> </li>
<li><a href="http://www.ninject.org">Ninject</a> </li>
<li><a href="http://code.google.com/p/autofac/">Autofac</a> </li>
<li><a href="http://www.codeplex.com/unity">Unity</a> </li>
<li><a href="http://www.springframework.net/">Spring.NET</a> </li>
<li>And probably others that I’m missing. </li>
</ul>
<p>Ironically, when you first start using an IoC framework, you might find that in trying to make a loosely-coupled, modular, application you end up shackling yourself to the framework you’re using for IoC. </p>
<p>For example, you start off using your own homegrown IoC framework, and then decide at some point in the future to use a different framework, like say StructureMap.&#160; Going through your codebase to make these changes can be quite the exercise in pain.</p>
<p>There are a couple of ways to isolate yourself from this kind of situation.&#160; I won’t get into all of them but instead will focus on the <a href="http://www.codeplex.com/CommonServiceLocator">Common Service Locator</a>. What is Common Service Locator?&#160; Well, allow me to cut and paste some text from the web site:</p>
<p>&quot;<em>The Common Service Locator library contains a shared interface for service location which application and framework developers can reference. The library provides an abstraction over IoC containers and service locators. Using the library allows an application to indirectly access the capabilities without relying on hard references. The hope is that using this library, third-party applications and frameworks can begin to leverage IoC/Service Location without tying themselves down to a specific implementation.</em>”</p>
<p>Blah blah blah – so what does all that mean?&#160; Well, in my own words, CSL is basically a wrapper around your IoC container which separates how you&#160; initialize/configure your IoC container from how you use it.&#160; This separation allows you to use your IoC container without knowing anything about it.</p>
<p>This separation is achieved by use of adapters for the particular IoC container that you want to use.&#160; These adapters are what do the dirty work of finding the service you need, in their own special way and totally transparent from your application code.&#160; Currently, the Common Service Locator has adapters for <a href="http://www.codeplex.com/CommonServiceLocator/Wiki/View.aspx?title=StructureMap%20Adapter&amp;referringTitle=Home">StructureMap</a>, <a href="http://www.codeplex.com/CommonServiceLocator/Wiki/View.aspx?title=Castle%20Windsor%20Adapter&amp;referringTitle=Home">Castle Windows</a>, <a href="http://www.codeplex.com/CommonServiceLocator/Wiki/View.aspx?title=Unity%20Adapter&amp;referringTitle=Home">Unity</a>, <a href="http://www.codeplex.com/CommonServiceLocator/Wiki/View.aspx?title=Spring%20.NET%20Adapter&amp;referringTitle=Home">Spring.NET</a>, and <a href="http://www.codeplex.com/CommonServiceLocator/Wiki/View.aspx?title=Autofac%20Adapter&amp;referringTitle=Home">autofac</a>. </p>
<p>Now, allow me an example of using the Common Service Locator with StructureMap. There is no special reason as to why StructureMap – it just happens to be what I find myself using these days.</p>
<p>Now, say I use the the following <a href="http://structuremap.sourceforge.net/RegistryDSL.htm">registry</a> to configure StructureMap:</p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> DefaultStructureMapRegistry: Registry</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>     <span style="color: #0000ff">public</span> DefaultStructureMapRegistry()</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>         ForRequestedType&lt;IDb4oConfiguration&gt;()</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span>             .TheDefaultIsConcreteType&lt;SimpleDb4oConfiguration&gt;();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span> }</pre>
</p></div>
</div>
<p>In a nutshell this says that every time StructureMap is asked to provided an object of type IDb4oConfiguration, it should instantiate a SimpleDb4oConfiguration object and return that.&#160; So, to get an instance of IDb4oConfiguration with StructureMap, I would do something like this:</p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> var db4oConfig = ObjectFactory.GetInstance&lt;IDb4oConfiguration&gt;();</pre>
</p></div>
</div>
<p>Pretty simple, but it does kind of tightly couples me to StructureMap.&#160; If I need/feel like/am forced at gunpoint to change my IoC container to something that is Not StructureMap, you can bet that there will be much wailing and gnashing of teeth on my part as I hunt through my code to make these changes.</p>
<p>Now enter the Common Service Locator.&#160; First, let’s take a peek at some interfaces for CSL.&#160; First an interface:</p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">namespace</span> Microsoft.Practices.ServiceLocation</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">interface</span> IServiceLocator : IServiceProvider</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>         <span style="color: #0000ff">object</span> GetInstance(Type serviceType);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span>         <span style="color: #0000ff">object</span> GetInstance(Type serviceType, <span style="color: #0000ff">string</span> key);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span>         IEnumerable&lt;<span style="color: #0000ff">object</span>&gt; GetAllInstances(Type serviceType);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span>         TService GetInstance&lt;TService&gt;();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span>         TService GetInstance&lt;TService&gt;(<span style="color: #0000ff">string</span> key);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  10:</span>         IEnumerable&lt;TService&gt; GetAllInstances&lt;TService&gt;();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  11:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  12:</span> }</pre>
</p></div>
</div>
<p>The IServiceLocator is an interface that your application will use when it requests something from your IoC container. </p>
<p>Another thing that CSL provides is a static class that your application would use to use a current IServiceLocator to request services.&#160; That static class looks something like:</p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">namespace</span> Microsoft.Practices.ServiceLocation</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">class</span> ServiceLocator</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> IServiceLocator Current { get; }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> SetLocatorProvider(ServiceLocatorProvider newProvider) {};</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span> }</pre>
</p></div>
</div>
<p>So, now lets see how we would request the default implementation of the IDb4oConfiguration service using CSL.&#160; First, we would initialize CSL:</p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> var registry = <span style="color: #0000ff">new</span> DefaultStructureMapRegistry();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> var container = <span style="color: #0000ff">new</span> global::StructureMap.Container(registry);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span> var smServiceLocator = <span style="color: #0000ff">new</span> StructureMapServiceLocator(container);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span> ServiceLocator.SetLocatorProvider(() =&gt; smServiceLocator );</pre>
</p></div>
</div>
<p>What is going on here? Allow me to provide a quick line by line explanation:</p>
<p>Line 1 we instantiate a new StructureMap registry.&#160; We then feed that registry to a StructureMap container in line 2.&#160; With line 3, we see that StructureMap container is then fed to the StructureMapServiceLocator, which is the SM adapter for the Common Service Locator.&#160; Finally, with line 4 we provide a lambda that CSL will use to fulfill future requests for services.</p>
<p>Now when our application wants to get an instance of IDb4oConfiguration it just politely asks CSL:</p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> var db4oConfig = ServiceLocator.Current.GetService&lt;IDb4oConfiguration&gt;();</pre>
</p></div>
</div>
<p>Pretty simple and clean, <a href="http://en.wikipedia.org/wiki/Eh#Canada">eh</a>?&#160; Now, when radical group the <em>Foundation for Unity as the Dominate IoC Container</em> sneaks into your cube and forces you at the point of a nerf gun to switch to Unity, you can do so with minimal disruption to your application. With a properly layered application, it would be as simple as coding a new UnityConfiguration layer and then using that instead of your StructureMapConfiguration layer on application startup.</p>
<p>Now, granted this is pretty trivialized example.&#160; There are other ways to solve this problem, but CSL does seem to take are of the grunt work for you so that you can just get going with things.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2009/03/19/common-service-locator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Every Time you [Ignore] a Test, a Puppy Dies</title>
		<link>http://www.opgenorth.net/2009/02/20/every-time-you-ignore-a-test-a-puppy-dies/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=every-time-you-ignore-a-test-a-puppy-dies</link>
		<comments>http://www.opgenorth.net/2009/02/20/every-time-you-ignore-a-test-a-puppy-dies/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 15:08:00 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2009/02/20/every-time-you-ignore-a-test-a-puppy-dies/</guid>
		<description><![CDATA[If you using a unit testing framework such as NUnit, you&#8217;re no doubt familiar with the [Ignore] attribute.  (Note:  I haven&#8217;t used MbUnit in a while, but I&#8217;m pretty sure that all this applies there as well.) For those who aren&#8217;t, when you adorn your [Test] with this attribute, then your test runner should pay [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.opgenorth.net/wp-content/uploads/2010/03/image001_2.jpg"><img style="display: inline; border: 0px;" title="image001_2" src="http://www.opgenorth.net/wp-content/uploads/2010/03/image001_2_thumb.jpg" border="0" alt="image001_2" width="244" height="174" /></a></p>
<p>If you using a unit testing framework such as <a href="http://www.nunit.org">NUnit</a>, you&#8217;re no doubt familiar with the <a href="http://www.nunit.org/index.php?p=ignore&amp;r=2.4.8">[Ignore]</a> attribute.  (Note:  I haven&#8217;t used <a href="http://www.mbunit.com">MbUnit</a> in a while, but I&#8217;m pretty sure that all this applies there as well.) For those who aren&#8217;t, when you adorn your [Test] with this attribute, then your test runner should pay no heed to this particular [Test].  Instead of going green or red, your test turns up as yellow in your test runner. At first blush, this seems handy &#8211; rather than deleting a failing or broken test you can have it [Ignore]d, much like your typical computer geek at a high school dance before the punch get&#8217;s spiked. Now you can deal with the wayward test on your own time with the pesky failure cluttering up your CI build (you do have a CI build box set up, right?).</p>
<p>Please bear with me while I submit to you: This isn&#8217;t a good idea. This is a bad idea. An ugly idea. The kind of bad, ugly idea than even <a href="http://www.igloocoder.com">Belcham</a>-esque quantities of scotch couldn&#8217;t make pretty. Why? Well, the whole point to having a unit test is to <strong>test something</strong>. If your test is failing, that means something is broken.  You should be addressing the cause of the failure and dealing with the problem now. Covering up the failure with some attribute kind of defeats the purpose of having the unit test in the first place. I mean, really, if you had open, festering lesions on your skin would you just cover them up with a band-aid and pretend nothing was wrong?  Odds are you&#8217;d go to a doctor and get that checked out.</p>
<p>Alternately, perhaps the test isn&#8217;t valid anymore: your application has changed/evolved and the code that you were testing isn&#8217;t around anymore. Then, get rid of the test! Delete it from your test fixtures, and don&#8217;t look back.</p>
<p>Granted the world we live in is not black and while.  Sometimes we&#8217;re working on things, and we only want tests to run when it is explicitly asked to run.  To handle this scenario, <a href="http://www.nunit.org">NUnit</a> provides the <a href="http://www.nunit.org/index.php?p=explicit&amp;r=2.4.8">[Explicit]</a> attribute.  This is a kinder, more gentle kind of ignore.  This instructs <a href="http://www.nunit.org">NUnit</a> to only run the test when it is told to run the test.  If you add a comment to the attribute, then it helps those going through the build log understand why the test is being run.  However it is still possible to run the test if desired.</p>
<pre style="border: 1px solid #cecece; padding: 5px; overflow: auto; background-color: #fbfbfb; min-height: 40px; width: 650px;">
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">[Explicit("<span style="color: #8b0000;">This test takes a really really really long time to run so we don't want to run it in this test suite every time</span>")]
</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">[Test]
</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> My_very_important_test()
</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">{
</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">    <span style="color: #008000;">// Test valuable things here</span>
</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">}</pre>
</pre>
<p>I know some people are going to protest my advice. So I will offer up this one last piece.  If you are going to [Ignore] a [Test] then please take advantage of the fact that you can add a comment to the Ignore which will show up when <a href="http://www.nunit.org">NUnit</a> ignores the test:</p>
<pre style="border: 1px solid #cecece; padding: 5px; overflow: auto; background-color: #fbfbfb; min-height: 40px; width: 650px;">
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">[Ignore("<span style="color: #8b0000;">This test is ignored as I wish to incur the wrath of Cthulhu (or his proxy)</span>")]
</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">[Test]
</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> My_very_important_test()
</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">{
</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">    <span style="color: #008000;">// Test valuable things here.</span>
</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">}</pre>
</pre>
<p>Now when your CI server runs your unit tests, you will have a nice friendly message that will inform others as to why the test is not running.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2009/02/20/every-time-you-ignore-a-test-a-puppy-dies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What&#8217;s In A Name?</title>
		<link>http://www.opgenorth.net/2008/08/26/whats-in-a-name/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=whats-in-a-name</link>
		<comments>http://www.opgenorth.net/2008/08/26/whats-in-a-name/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 01:28:00 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2008/08/26/whats-in-a-name/</guid>
		<description><![CDATA[As I was driving home today, I couldn&#8217;t help notice something.&#160; Microsoft&#8217;s ASP.NET MVC framework is still in beta, and was only announced last October.&#160; To my knowledge, there are currently three projects in the Edmonton area based off this framework. Castle Monorail has been around for much longer, three years or so?&#160; It&#8217;s still [...]]]></description>
			<content:encoded><![CDATA[<p>As I was driving home today, I couldn&#8217;t help notice something.&#160; Microsoft&#8217;s ASP.NET MVC framework is still in beta, and was only announced last October.&#160; To my knowledge, there are currently three projects in the <a href="http://maps.google.ca/maps?q=Edmonton,+Alberta&amp;ie=UTF8&amp;oe=utf-8&amp;client=firefox-a&amp;ll=53.540307,-113.510742&amp;spn=18.606218,57.128906&amp;z=5&amp;iwloc=addr">Edmonton</a> area based off this framework.</p>
<p>Castle Monorail has been around for much longer, three years or so?&#160; It&#8217;s still listed as a release candidate on it&#8217;s website, but I&#8217;d say Monorail is suitable for production.&#160; Currently, I am not aware of any projects in the Edmonton that are based off this framework.</p>
<p>I guess this is anecdotal evidence that you won&#8217;t get fired for sticking with Microsoft. <img src='http://www.opgenorth.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The two frameworks have quite a few similarities.&#160; IIRC, in Austin last fall Scott Guthrie did mention that the ASP.NET MVC framework was influenced to some degree by Monorail.</p>
<p>Regardless, it&#8217;s good news.&#160; Personally, I like both frameworks, and would prefer either of them to Web Forms.&#160; YMMV.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2008/08/26/whats-in-a-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Cleanup with Resharper</title>
		<link>http://www.opgenorth.net/2007/12/17/code-cleanup-with-resharper/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=code-cleanup-with-resharper</link>
		<comments>http://www.opgenorth.net/2007/12/17/code-cleanup-with-resharper/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 04:12:00 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2007/12/17/code-cleanup-with-resharper/</guid>
		<description><![CDATA[As most Resharpies know, when you&#8217;re using Resharper you can reformat your code. A nice feature is that you can use this reformat code to also organize and layout your code files the way you like it. For example, Kyle Baley did post on how to how to use the format code to get rid [...]]]></description>
			<content:encoded><![CDATA[<p>As most Resharpies know, when you&#8217;re using Resharper you can reformat your code. A nice feature is that you can use this reformat code to also organize and layout your code files the way you like it.</p>
<p>For example, <a href="http://codebetter.com/blogs/kyle.baley/archive/2007/12/17/removing-regions-or-quot-how-to-keep-your-code-expanded-quot.aspx">Kyle Baley did post</a> on how to how to use the format code to get rid of regions. His techique is a bit unrefined &#8211; his revolutionary, dogmatic zeal he will clobber all regions and do nothing else &#8211; but still handy.&#160;&#160; Myself, I&#8217;m a bit more compulsive / fussy when it comes to the layout of my code. Not only do I want regions gone, but I want the code to appear in a certain order. Lucky for me that Reformat Code does this for me. Here is the <a href="http://www.opgenorth.net/Data/Sites/1/Files/ResharperPatterns.xml">Type Member Layout pattern I use</a>. If you want to use it, just paste it into the type member layout window in Resharper.</p>
<p>What this will do, when you ask Resharper to Reformat Your Code, is the following: Remove all regions Sort your code, with the following order:</p>
<ul>
<li>any COM Interop interfaces </li>
<li>public delegates </li>
<li>public enums </li>
<li>constants (sorted alphabetically) </li>
<li>fields (sorted with readonly first, and alphabetically) </li>
<li>static constructors </li>
<li>constructors </li>
<li>properties (sorted alphabetically) </li>
<li>methods (sorted alphabetically) </li>
<li>anything else (sorted alphabetically) </li>
</ul>
<p>For the sake of brevity, I&#8217;m not giving a detailed breakdown of the Type Member Layout Pattern syntax. Well, brevity and the fact that I&#8217;m not 100% certain on a lot of it and don&#8217;t want to unintentionally say something wrong. I do believe that the format is pretty straight forward, so you look at it and make your own adjustments.</p>
<p>However, to give you an example. Imagine for a moment that you wanted to surround any interface methods in a #region. First off, don&#8217;t tell Kyle. Might be a good idea <a href="http://laribee.com/blog/2007/07/22/why-regions-are-fugly/">not to mention it to David Laribee</a> while you&#8217;re at it. Secondly, add the following snippet: </p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">&lt;</span><span style="color: #800000">Entry</span><span style="color: #0000ff">&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  <span style="color: #0000ff">&lt;</span><span style="color: #800000">Match</span><span style="color: #0000ff">&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">And</span> <span style="color: #ff0000">Weight</span>=<span style="color: #0000ff">&quot;100&quot;</span><span style="color: #0000ff">&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">      <span style="color: #0000ff">&lt;</span><span style="color: #800000">Kind</span> <span style="color: #ff0000">Is</span>=<span style="color: #0000ff">&quot;member&quot;</span><span style="color: #0000ff">/&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">        <span style="color: #0000ff">&lt;</span><span style="color: #800000">ImplementsInterface</span><span style="color: #0000ff">/&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">And</span><span style="color: #0000ff">&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Match</span><span style="color: #0000ff">&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  <span style="color: #0000ff">&lt;</span><span style="color: #800000">Sort</span><span style="color: #0000ff">&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">ImplementsInterface</span> <span style="color: #ff0000">Immediate</span>=<span style="color: #0000ff">&quot;true&quot;</span><span style="color: #0000ff">/&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">      <span style="color: #0000ff">&lt;</span><span style="color: #800000">Kind</span> <span style="color: #ff0000">Order</span>=<span style="color: #0000ff">&quot;property method&quot;</span><span style="color: #0000ff">/&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">      <span style="color: #0000ff">&lt;</span><span style="color: #800000">Readonly</span><span style="color: #0000ff">/&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">      <span style="color: #0000ff">&lt;</span><span style="color: #800000">Name</span><span style="color: #0000ff">/&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Sort</span><span style="color: #0000ff">&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  <span style="color: #0000ff">&lt;</span><span style="color: #800000">Group</span><span style="color: #0000ff">&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">ImplementsInterface</span> <span style="color: #ff0000">Immediate</span>=<span style="color: #0000ff">&quot;true&quot;</span> <span style="color: #ff0000">Region</span>=<span style="color: #0000ff">&quot;${ImplementsInterface} Members&quot;</span><span style="color: #0000ff">/&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Group</span><span style="color: #0000ff">&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">&lt;/</span><span style="color: #800000">Entry</span><span style="color: #0000ff">&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
</pre>
<p>What this will do is, for each member of your class that is part of an interface implementation (the whole part), sort it by it&#8217;s name (the part), and surround them with a #region (). If you look at my <a href="http://www.opgenorth.net/Data/Sites/1/Files/ResharperPatternsWithInterface.xml">Resharper Patterns with Interfaces</a> sample, you can see by the position with in the element that the interface #region will appear at almost the end of your *.CS file. I hope now that this will appease your inner obsessive compulsive self.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2007/12/17/code-cleanup-with-resharper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with Open Source: OpenDental</title>
		<link>http://www.opgenorth.net/2007/11/15/fun-with-open-source-opendental/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=fun-with-open-source-opendental</link>
		<comments>http://www.opgenorth.net/2007/11/15/fun-with-open-source-opendental/#comments</comments>
		<pubDate>Fri, 16 Nov 2007 06:30:00 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mono]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2007/11/15/fun-with-open-source-opendental/</guid>
		<description><![CDATA[The past week I&#8217;ve been dabbling with an open source program called Open Dental &#8211; mostly trying to see if can get it to compile under Mono, and running under Linux.&#160; I figure that this would be a good opportunity to and work with a cross platform application. According to their website, Open Dental has [...]]]></description>
			<content:encoded><![CDATA[<p>The past week I&#8217;ve been dabbling with an open source program called <a href="http://www.open-dent.com/">Open Dental</a> &#8211; mostly trying to see if can get it to compile under Mono, and running under Linux.&#160; I figure that this would be a good opportunity to and work with a cross platform application. </p>
<p>According to their website, Open Dental has been supported under Linux since v4.7.&#160; Here are some notes of my efforts so far.</p>
<p>You will need Mono v1.2.5.&#160; It seems that there is a problem with the Linux binary installer ( a known bug that will be corrected in 1.2.6).&#160; I used the <a href="http://www.mono-project.com/Downloads">OpenSUSE 10.2 VMWare image</a> which had a 1.2.5 install all set up.&#160; That solved my problem of getting a current Linux distro with the most recent version of Mono.</p>
<p>There is a website for getting <a href="http://opendental.carlier-online.be/ubuntu.html">Open Dental to run under Ubuntu</a>, and instructions on how to <a href="http://opendental.carlier-online.be/source.html">compile on Linux</a>.&#160; I couldn&#8217;t get the application to compile under Linux using those instructions.&#160; I suspect that they are a bit out of date.&#160; What I ended up doing was compiling the application in VS2005, setting the build to LinuxRelease.&#160; I then copied the binaries over to my OpenSUSE VM, and ran Open Dental.</p>
<p>Now, Open Dental uses MySQL 5 for a database backend.&#160; The problem that I ran into next is that the database script that is provided to setup the database is for a very old version of Open Dental (like v3.x).&#160; Open Dental is supposed to be smart enough to update the database to the correct version.&#160; However the DB upgrading process seemed to keep crashing.</p>
<p>What I ended up doing was installing the trial version of Open Dental.&#160; This created a database for me.&#160; Once I had a database, the application seemed to run.</p>
<p>A curious thing is that when I would try to run Open Dental on Windows, using Mono 1.2.5.2, the application crashes.&#160; No such problems running under Linux though.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2007/11/15/fun-with-open-source-opendental/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is Right About .NET?</title>
		<link>http://www.opgenorth.net/2007/11/04/what-is-right-about-net/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=what-is-right-about-net</link>
		<comments>http://www.opgenorth.net/2007/11/04/what-is-right-about-net/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 00:53:00 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2007/11/04/what-is-right-about-net/</guid>
		<description><![CDATA[Recently, on one of the mailing lists I subscribe to, a member starting bashing .NET. A bit curious as to why there was this strong hatred of .NET, I posed a simple question: What is wrong with .NET? The answer I got back somewhat suprised me: I guess the standard reply is, what is right [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, on one of the mailing lists I subscribe to, a member starting bashing .NET. A bit curious as to why there was this strong hatred of .NET, I posed a simple question:</p>
<p><em>What is wrong with .NET?</em></p>
<p>The answer I got back somewhat suprised me:</p>
<p><em>I guess the standard reply is, what is right about .NET?&#160; .NET was invented so that M$ could provide software as a service. You would end up with a minimal OS on the disk, and no applications. When you turned your computer on, it would download whatever applications you needed, or did so on demand; if your subscription was paid up.</em></p>
<p><em>That was the PR on .NET when it first came out, to my best recollection.</em></p>
<p><em>Your PC was useless, unless your subscription was up to date. Again, as far as I remember, this was the original intention of .NET. It doesn&#8217;t look like things progressed quite the way they were supposed to.</em></p>
<p>I felt, that given the opinion was largely based on an erroneous perception, that I should respond:</p>
<p>Yes, the original PR campaign around .NET was a bit of a disaster, if you ask me. It did more to confuse people than anything. You&#8217;d mention .NET, and some people would think you were talking about the programming/software development environment, some people thought you were talking about the next version of Windows, and yet others still thought that you were the service concept that was mentioned. And lets just quietly agree to push Passport into a dark pit along with Microsoft &quot;Bob&quot;.</p>
<p>These days, when people speak of .NET, they are speaking of the software development platform &#8211; i.e. the tools to write software. The concept of .NET as a Microsoft service faded away a while ago.</p>
<p>Now, I will admit that I might have a bit of a bias. My OO programming started with Clipper (using ClassY), then C++, then Java. And when .NET came out in beta, I switched to that.&#160; I&#8217;ve also dabbled a bit using OO in Perl.</p>
<p>In the 5+ years I have been using .NET, the only &quot;subscription&quot; I have paid is for my MSDN subscription, and that I have only paid for since I started consulting. I have written .NET applications without having an MSDN subscription. I know of people that write .NET applications using nothing fancier than emacs. In fact, I know of people that write .NET applications without Windows or using anything from Microsoft. I have never had, nor heard of, anyone having their custom applications &quot;expire&quot; because their &quot;subscription&quot; was unpaid. .NET doesn&#8217;t force any downloads on you &#8211; that is Windows Update.</p>
<p>Using .NET is no different that using Java, IMO. The basic concepts behind each are almost the same. There are pros and cons to each, but in the end it comes down to your preferences (or that of your client). I&#8217;ve worked at places that use both. The .NET camp does borrow a lot from Java, many Open Source Java tools have been ported to .NET. Many of the software engineering principles that the Java camp adopted years ago are finally start penetrate into the .NET world.</p>
<p>So, if you ask me what is right about .NET, I&#8217;d say that for many software applications, it&#8217;s a good choice. I can write web application, Windows applications, Windows services, daemons, and web services. I have have a good set of libraries that allow me to concentration on what I need to get my job done, and not spend so much time on &quot;plumbing&quot; &#8211; unless I want to.</p>
<p>I can use the same language for each every application, or I can use one of the many languages that are supported by .NET (C#, VB.NET, Java, C++, Python, Ruby, Perl, PHP, FORTRAN, COBOL, and a large, large, list of others). I can share my .NET components with each other, regardless of the language I use. I can (and have) also share my newer .NET components with my older Delphi/VB/C++ applications. Thanks to Mono, you can now run your .NET applications on platforms other than Wintel.&#160; </p>
<p>So, for developing software applications, pick your poison. .NET is definitely a viable choice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2007/11/04/what-is-right-about-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why I Love NHibernate</title>
		<link>http://www.opgenorth.net/2007/10/31/why-i-love-nhibernate/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=why-i-love-nhibernate</link>
		<comments>http://www.opgenorth.net/2007/10/31/why-i-love-nhibernate/#comments</comments>
		<pubDate>Thu, 01 Nov 2007 01:28:00 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2007/10/31/why-i-love-nhibernate/</guid>
		<description><![CDATA[Why I love NHibernate: I am rather please by the fact that a database schema change involving the creation of six new tables, three one-to-many relationships, and a many-to-many relationship (which includes a sort order on the join table) can be taken care of inside of seven easy hours.&#160; It probably would/could have been less, [...]]]></description>
			<content:encoded><![CDATA[<p>Why I love <a href="http://www.nhibernate.org">NHibernate</a>:</p>
<p>I am rather please by the fact that a database schema change involving the creation of six new tables, three one-to-many relationships, and a many-to-many relationship (which includes a sort order on the join table) can be taken care of inside of seven easy hours.&#160; It probably would/could have been less, but I crafted the HBM and class files by hand and had a few typos which hide themselves well.&#160; This also included the time it took to create some quick integration tests to ensure that CRUD is working.</p>
<p>Now, of course, there are other changes to the domain that need to be done to deal with these new tables, but <a href="http://www.nhibernate.org">NHibernate</a> frees me from paying a significant &quot;database tax&quot;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2007/10/31/why-i-love-nhibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
