<?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/tag/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>Where Did the Time Go?</title>
		<link>http://www.opgenorth.net/2010/01/28/where-did-the-time-go/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=where-did-the-time-go</link>
		<comments>http://www.opgenorth.net/2010/01/28/where-did-the-time-go/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 05:28:58 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Site News]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2010/01/28/where-did-the-time-go/</guid>
		<description><![CDATA[Yeah, I’ve been kind of quiet as of late.&#160; So quiet, I suspect that some people might be wondering if something happened.&#160; I was a bit surprised to see that the last time I had blogged was after TechDays in Calgary.&#160; Well, nothing significant has happened &#8211; just a bit of laziness augmented by a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.opgenorth.net/wp-content/uploads/2010/01/tumbleweed1.jpg"><img title="tumbleweed" style="border-right: 0px; border-top: 0px; display: inline; margin-left: 0px; border-left: 0px; margin-right: 0px; border-bottom: 0px" height="75" alt="tumbleweed" src="http://www.opgenorth.net/wp-content/uploads/2010/01/tumbleweed_thumb1.jpg" width="90" align="left" border="0" /></a>Yeah, I’ve been kind of quiet as of late.&#160; So quiet, I suspect that some people might be wondering if something happened.&#160; I was a bit surprised to see that the last time I had blogged was after TechDays in Calgary.&#160; Well, nothing significant has happened &#8211; just a bit of laziness augmented by a touch of tech-burnout compounded by the odd bit of single malt scotch.</p>
<p>So, now that one month is almost up on 2010, I figured that it was time to start blogging about something again.&#160; The first trick to this, of course, was to figure out what I wanted to do in 2010.&#160; It does seem like there will be a lot of interesting things, technically speaking, coming up this year.</p>
<p>A couple of new things I want to look at over the remaining 11 months:</p>
<p>Mobile development, particularly with a focus on Android<a href="http://www.opgenorth.net/wp-content/uploads/2010/01/androidrobotlogo1.jpg"><img title="android-robot-logo1" style="border-right: 0px; border-top: 0px; display: inline; margin-left: 0px; border-left: 0px; margin-right: 0px; border-bottom: 0px" height="24" alt="android-robot-logo1" src="http://www.opgenorth.net/wp-content/uploads/2010/01/androidrobotlogo1_thumb.jpg" width="22" border="0" /></a>.&#160; For the latter half of 2009 I have been dabbling in Android.&#160; I believe that it’s time to go out on a bender, and in a drunken stupor get some embarrassing tattoo and join the Android Army.&#160; So far, I’m at two out of three.&#160; Not bad, huh?</p>
<p><a href="http://www.opgenorth.net/wp-content/uploads/2010/01/AndroidArmy.jpg"><img title="AndroidArmy" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="117" alt="AndroidArmy" src="http://www.opgenorth.net/wp-content/uploads/2010/01/AndroidArmy_thumb.jpg" width="244" border="0" /></a>&#160;</p>
<p>Ruby is another technology I’d like to explore – particularly Rails.&#160; I can help but think that the opinionated view that Rails development has taken is the way to go for the bulk of web development.&#160; A lot of websites are basically just forms over data, and Rails seems to address that concern rather well.&#160; To bad nobody around here in Edmonton does much Rails development.</p>
<p>.NET 4.0 and ASP.NET MVC2.&#160; I know there is a lot of debate between Web Forms and ASP.NET MVC.&#160; Personally, I think MVC is the better way.&#160; Probably best to keep abreast of what is going on in the ASP.NET MVC world.&#160; And, of course, the DLR in .NET will come to maturity soon.&#160; By maturity I mean widespread acceptance.&#160; If this happens, then maybe developers won’t get so hung up on languages:&#160; i.e. “I’m a C# guy so VB.NET sucks”.</p>
<p>And finally, a guy needs hobbies.&#160; Now granted, my past hobbies of alcohol and <a href="http://www.opgenorth.net/images/tom_AR.jpg">guns</a> (no, not together at the same time) have served me well for the past 20 years or so. However, they are hard hobbies to share with my sons at this point in time.&#160; So, at the start of winter I expanded the geek factor of my sons (and myself) by getting back into <a href="http://www.games-workshop.com">Warhammer</a>.&#160; Now the last time I played was about 20 years ago, with the 3rd edition rules.&#160; In fact, I still have some of the books in my basement from back then.&#160; Anyway, picked up <a href="http://www.games-workshop.com/gws/content/article.jsp?aId=700012a&amp;setLocale=en_CA&amp;amp;_requestid=1241948">The Battle for Skull Pass</a> boxed set.&#160; My son rather likes the <a href="http://www.games-workshop.com/gws/catalog/landingArmy.jsp?catId=cat210008&amp;rootCatGameStyle=">Dwarfs</a>.&#160; I suspect it’s because he’s similar in stature/height to the stunties.&#160; Myself, while I find the <a href="http://www.games-workshop.com/gws/catalog/landingArmy.jsp?catId=cat50030&amp;rootCatGameStyle=">Greenskins</a> amusing, I suspect I might have to move on and get serious with <a href="http://www.games-workshop.com/gws/catalog/landingArmy.jsp?catId=cat40032&amp;rootCatGameStyle=">Dark Elves</a>.</p>
<p>Anyway, enough for tonight.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2010/01/28/where-did-the-time-go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling ASP.NET MVC on Mono 2.4.3</title>
		<link>http://www.opgenorth.net/2009/11/11/compiling-asp-net-mvc-on-mono-2-4-3/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=compiling-asp-net-mvc-on-mono-2-4-3</link>
		<comments>http://www.opgenorth.net/2009/11/11/compiling-asp-net-mvc-on-mono-2-4-3/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 16:52:17 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Mono]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2009/11/11/compiling-asp-net-mvc-on-mono-2-4-3/</guid>
		<description><![CDATA[Out of intellectual curiosity, I sparked up MonoDevelop and decided to see what would happen when I tried to compile the ASP.NET MVC source code. I figured that it would Just Work.&#160; After all, I can use the .NET compiled assembly with no problems on Mono, so there really shouldn&#8217;t be any problems trying to [...]]]></description>
			<content:encoded><![CDATA[<p>Out of intellectual curiosity, I sparked up <a href="http://www.monodevelop.com">MonoDevelop</a> and decided to see what would happen when I tried to compile the <a href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24471">ASP.NET MVC source code</a>. I figured that it would Just Work.&#160; After all, I can use the .NET compiled assembly with no problems on <a href="http://www.go-mono.com">Mono</a>, so there really shouldn&#8217;t be any problems trying to compile the code.&#160; Bad news is that there is one minor glitch.&#160; Good news is the glitch is easy to work around and has already been fixed so it shouldn&#8217;t be a problem for future version of Mono. </p>
<p>When you compile, here is what you get:</p>
<p><font face="monospace">Compilation failed: 1 error(s), 0 warnings</font>
<p>/home/tom/Projects/MVC-MS-Pl-original/MVC-MS-Pl/Mvc/FormCollection.cs(25,6): error CS0246: The type or namespace name `FormCollectionBinder&#8217; could not be found. Are you missing a using directive or an assembly reference?</p>
<p>Build complete &#8212; 1 error, 0 warnings</p>
</p>
<p>So, this kind of surprised me.&#160; Looking at the code, I did see the FormCollectionBinder in the code, it&#8217;s an embedded class within System.Web.Mvc.FormCollection, check out lines 68-88 below:   </p>
<div>
<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: #008000">/* **************************************************************************** </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">   2:</span> <span style="color: #008000"> * </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: #008000"> * Copyright (c) Microsoft Corporation. All rights reserved. </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">   4:</span> <span style="color: #008000"> * </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: #008000"> * This software is subject to the Microsoft Public License (Ms-PL).  </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">   6:</span> <span style="color: #008000"> * A copy of the license can be found in the license.htm file included  </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">   7:</span> <span style="color: #008000"> * in this distribution. </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> <span style="color: #008000"> * </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">   9:</span> <span style="color: #008000"> * You must not remove this notice, or any other, from this software. </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">  10:</span> <span style="color: #008000"> * </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">  11:</span> <span style="color: #008000"> * ***************************************************************************/</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>
<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">  13:</span> <span style="color: #0000ff">namespace</span> System.Web.Mvc { </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">  14:</span>     <span style="color: #0000ff">using</span> System; </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">  15:</span>     <span style="color: #0000ff">using</span> System.Collections.Generic; </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">  16:</span>     <span style="color: #0000ff">using</span> System.Collections.Specialized; </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">  17:</span>     <span style="color: #0000ff">using</span> System.Diagnostics.CodeAnalysis; </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">  18:</span>     <span style="color: #0000ff">using</span> System.Globalization; </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">  19:</span>     <span style="color: #0000ff">using</span> System.Web.Mvc.Resources; </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">  20:</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">  21:</span>     [SuppressMessage(<span style="color: #006080">&quot;Microsoft.Usage&quot;</span>, <span style="color: #006080">&quot;CA2237:MarkISerializableTypesWithSerializable&quot;</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">  22:</span>         Justification = <span style="color: #006080">&quot;It is not anticipated that users will need to serialize this type.&quot;</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">  23:</span>     [SuppressMessage(<span style="color: #006080">&quot;Microsoft.Design&quot;</span>, <span style="color: #006080">&quot;CA1035:ICollectionImplementationsHaveStronglyTypedMembers&quot;</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">  24:</span>         Justification = <span style="color: #006080">&quot;It is not anticipated that users will call FormCollection.CopyTo().&quot;</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">  25:</span>     [FormCollectionBinder] </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">  26:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> FormCollection : NameValueCollection { </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">  27:</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">  28:</span>         <span style="color: #0000ff">public</span> FormCollection() { </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">  29:</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">  30:</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">  31:</span>         <span style="color: #0000ff">public</span> FormCollection(NameValueCollection collection) { </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">  32:</span>             <span style="color: #0000ff">if</span> (collection == <span style="color: #0000ff">null</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">  33:</span>                 <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentNullException(<span style="color: #006080">&quot;collection&quot;</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">  34:</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">  35:</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">  36:</span>             Add(collection); </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">  37:</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">  38:</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">  39:</span>         <span style="color: #0000ff">public</span> IDictionary&lt;<span style="color: #0000ff">string</span>, ValueProviderResult&gt; ToValueProvider() { </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">  40:</span>             CultureInfo currentCulture = CultureInfo.CurrentCulture; </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">  41:</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">  42:</span>             Dictionary&lt;<span style="color: #0000ff">string</span>, ValueProviderResult&gt; dict = <span style="color: #0000ff">new</span> Dictionary&lt;<span style="color: #0000ff">string</span>, ValueProviderResult&gt;(StringComparer.OrdinalIgnoreCase); </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">  43:</span>             <span style="color: #0000ff">string</span>[] keys = AllKeys; </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">  44:</span>             <span style="color: #0000ff">foreach</span> (<span style="color: #0000ff">string</span> key <span style="color: #0000ff">in</span> keys) { </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">  45:</span>                 <span style="color: #0000ff">string</span>[] rawValue = GetValues(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">  46:</span>                 <span style="color: #0000ff">string</span> attemptedValue = <span style="color: #0000ff">this</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">  47:</span>                 ValueProviderResult vpResult = <span style="color: #0000ff">new</span> ValueProviderResult(rawValue, attemptedValue, currentCulture); </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">  48:</span>                 dict[key] = vpResult; </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">  49:</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">  50:</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">  51:</span>             <span style="color: #0000ff">return</span> dict; </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">  52:</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">  53:</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">  54:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">virtual</span> ValueProviderResult GetValue(<span style="color: #0000ff">string</span> name) { </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">  55:</span>             <span style="color: #0000ff">if</span> (String.IsNullOrEmpty(name)) { </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">  56:</span>                 <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentException(MvcResources.Common_NullOrEmpty, <span style="color: #006080">&quot;name&quot;</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">  57:</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">  58:</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">  59:</span>             <span style="color: #0000ff">string</span>[] rawValue = GetValues(name); </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">  60:</span>             <span style="color: #0000ff">if</span> (rawValue == <span style="color: #0000ff">null</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">  61:</span>                 <span style="color: #0000ff">return</span> <span style="color: #0000ff">null</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">  62:</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">  63:</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">  64:</span>             <span style="color: #0000ff">string</span> attemptedValue = <span style="color: #0000ff">this</span>[name]; </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">  65:</span>             <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> ValueProviderResult(rawValue, attemptedValue, CultureInfo.CurrentCulture); </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">  66:</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">  67:</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">  68:</span>         <span style="color: #0000ff">private</span> <span style="color: #0000ff">sealed</span> <span style="color: #0000ff">class</span> FormCollectionBinderAttribute : CustomModelBinderAttribute { </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">  69:</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">  70:</span>             <span style="color: #008000">// since the FormCollectionModelBinder.BindModel() method is thread-safe, we only need to keep </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">  71:</span>             <span style="color: #008000">// a single instance of the binder around </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">  72:</span>             <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">readonly</span> FormCollectionModelBinder _binder = <span style="color: #0000ff">new</span> FormCollectionModelBinder(); </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">  73:</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">  74:</span>             <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> IModelBinder GetBinder() { </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">  75:</span>                 <span style="color: #0000ff">return</span> _binder; </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">  76:</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">  77:</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">  78:</span>             <span style="color: #008000">// this class is used for generating a FormCollection object </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">  79:</span>             <span style="color: #0000ff">private</span> <span style="color: #0000ff">sealed</span> <span style="color: #0000ff">class</span> FormCollectionModelBinder : IModelBinder { </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">  80:</span>                 <span style="color: #0000ff">public</span> <span style="color: #0000ff">object</span> BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { </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">  81:</span>                     <span style="color: #0000ff">if</span> (controllerContext == <span style="color: #0000ff">null</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">  82:</span>                         <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentNullException(<span style="color: #006080">&quot;controllerContext&quot;</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">  83:</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">  84:</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">  85:</span>                     <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> FormCollection(controllerContext.HttpContext.Request.Form); </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">  86:</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">  87:</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">  88:</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">  89:</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">  90:</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">  91:</span> }</pre>
</p></div>
</div>
<p>The version of Mono 2.4.3 I have doesn&#8217;t compile the class FormCollection because the FormCollectionBinderAttribute is inside the FormCollection class.&#160; This is the bug, and it has since been fixed.&#160; Easy ways to get around this:</p>
<ol>
<li>Just use the binary assembly from Microsoft for ASP.NET MVC. </li>
<li>Build your own Mono with the fix included </li>
<li>Move the code for FormCollectionBinderAttribute class outside of the code for the FormCollection class. </li>
</ol>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=f2ca890b-2b86-8d88-a1e6-06841221cc73" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2009/11/11/compiling-asp-net-mvc-on-mono-2-4-3/feed/</wfw:commentRss>
		<slash:comments>0</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>TypeMock, TestDriven.NET, and Red Tests</title>
		<link>http://www.opgenorth.net/2008/10/18/typemock-testdriven-net-and-red-tests/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=typemock-testdriven-net-and-red-tests</link>
		<comments>http://www.opgenorth.net/2008/10/18/typemock-testdriven-net-and-red-tests/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 00:34:00 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2008/10/18/typemock-testdriven-net-and-red-tests/</guid>
		<description><![CDATA[Lately I&#8217;ve been experimenting with TypeMock Isolator,&#160; and it&#8217;s new AAA syntax.&#160; For the past two years I&#8217;ve been a diehard Rhino.Mocks kind of guy, but figured that it&#8217;s time to check out other tools.&#160; Anyway, I had a situation where a unit test of mine was failing when I ran it with TestDriven.NET, but [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been experimenting with <a href="http://www.typemock.com/">TypeMock Isolator</a>,&#160; and it&#8217;s new AAA syntax.&#160; For the past two years I&#8217;ve been a diehard Rhino.Mocks kind of guy, but figured that it&#8217;s time to check out other tools.&#160; Anyway, I had a situation where a unit test of mine was failing when I ran it with <a href="http://www.testdriven.net/">TestDriven.NET</a>, but would pass when I ran it using the unit test runner in <a href="http://www.jetbrains.com/resharper">Resharper 4.1</a>.</p>
<p>Usually when I develop, I write individual tests and then run individually with TestDriven.NET and collectively with Resharper.&#160; In this case, as I was writing one unit test, it kept failing with TestDriven.NET.&#160; At first I thought it was just me being stupid (always a good place to start), and then I was worried that perhaps the documentation for TypeMock was to blame.&#160; So, I sent a email to Avi at TypeMock, mostly expecting confirmation of my stupidity.</p>
<p>Turns out the problem in this case was pretty obscure one (to me).&#160; At home, I do my development in a VM running Windows 2008 64 bit.&#160; When Resharper runs your unit tests, it does in a 32 bit process.&#160; TD.NET, on a 64bit OS,&#160; runs as a 64 bit process.&#160; If you get TD.NET to run as a 32 bit process, then your tests will run fine under TD.NET.</p>
<p>To do so, from the Visual Studio 2008 Command Prompt, change to the directory that you have TD.NET installed in.&#160; Then use corflags:</p>
<p><font face="Courier New">corflags /32bit+ ProcessInvocation.exe</font></p>
<p>Note that it&#8217;s probably best to do this when logged in as the Administrator.</p>
<p>I will say that I was happy with the support I got from the guys (Avi, Gil and Ohad) at TypeMock.&#160; Given the fact that we&#8217;re about a half a world apart (western Canada vs. Isreal), they provided prompt, excellent support.&#160; My thanks to them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2008/10/18/typemock-testdriven-net-and-red-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TypeMock, TestDriven.NET, and Red Tests</title>
		<link>http://www.opgenorth.net/2008/10/18/typemock-testdriven-net-and-red-tests-2/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=typemock-testdriven-net-and-red-tests-2</link>
		<comments>http://www.opgenorth.net/2008/10/18/typemock-testdriven-net-and-red-tests-2/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 07:05:00 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2008/10/18/typemock-testdriven-net-and-red-tests-2/</guid>
		<description><![CDATA[Lately I&#8217;ve been experimenting with TypeMock Isolator,&#160; and it&#8217;s new AAA syntax.&#160; For the past two years I&#8217;ve been a diehard Rhino.Mocks kind of guy, but figured that it&#8217;s time to check out other tools.&#160; Anyway, I had a situation where a unit test of mine was failing when I ran it with TestDriven.NET, but [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been experimenting with <a href="http://www.typemock.com/">TypeMock Isolator</a>,&#160; and it&#8217;s new AAA syntax.&#160; For the past two years I&#8217;ve been a diehard Rhino.Mocks kind of guy, but figured that it&#8217;s time to check out other tools.&#160; Anyway, I had a situation where a unit test of mine was failing when I ran it with <a href="http://www.testdriven.net/">TestDriven.NET</a>, but would pass when I ran it using the unit test runner in <a href="http://www.jetbrains.com/resharper">Resharper 4.1</a>.</p>
<p>Usually when I develop, I write individual tests and then run individually with TestDriven.NET and collectively with Resharper.&#160; In this case, as I was writing one unit test, it kept failing with TestDriven.NET.&#160; At first I thought it was just me being stupid (always a good place to start), and then I was worried that perhaps the documentation for TypeMock was to blame.&#160; So, I sent a email to Avi at TypeMock, mostly expecting confirmation of my stupidity. </p>
<p>Turns out the problem in this case was pretty obscure one (to me).&#160; At home, I do my development in a VM running Windows 2008 64 bit.&#160; When Resharper runs your unit tests, it does in a 32 bit process.&#160; TD.NET, on a 64bit OS,&#160; runs as a 64 bit process.&#160; If you get TD.NET to run as a 32 bit process, then your tests will run fine under TD.NET.</p>
<p>To do so, from the Visual Studio 2008 Command Prompt, change to the directory that you have TD.NET installed in.&#160; Then use corflags:</p>
<p>corflags /32bit+ ProcessInvocation.exe</p>
<p>Note that it&#8217;s probably best to do this when logged in as the Administrator.</p>
<p>I will say that I was happy with the support I got from the guys (Avi, Gil and Ohad) at TypeMock.&#160; Given the fact that we&#8217;re about a half a world apart (western Canada vs. Isreal), they provided prompt, excellent support.&#160; My thanks to them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2008/10/18/typemock-testdriven-net-and-red-tests-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mono 2.0 Released</title>
		<link>http://www.opgenorth.net/2008/10/06/mono-2-0-released/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mono-2-0-released</link>
		<comments>http://www.opgenorth.net/2008/10/06/mono-2-0-released/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 00:32:00 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2008/10/06/mono-2-0-released/</guid>
		<description><![CDATA[I know it&#8217;s hard to beat my shocking announcement from a couple of days ago, but I feel that this one is even more important:&#160; Mono 2.0 has been released.&#160; Read the full details, go forth, and code.]]></description>
			<content:encoded><![CDATA[<p>I know it&#8217;s hard to beat my <a href="http://www.opgenorth.net/2008/10/09/where-windows-beats-linux/">shocking announcement</a> from a couple of days ago, but I feel that this one is even more important:&#160; Mono 2.0 has been released.&#160; <a href="http://www.mono-project.com/Release_Notes_Mono_2.0">Read the full details</a>, go forth, and code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2008/10/06/mono-2-0-released/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>ASP.NET Web Services and jQuery/AJAX</title>
		<link>http://www.opgenorth.net/2008/05/22/asp-net-web-services-and-jqueryajax/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=asp-net-web-services-and-jqueryajax</link>
		<comments>http://www.opgenorth.net/2008/05/22/asp-net-web-services-and-jqueryajax/#comments</comments>
		<pubDate>Fri, 23 May 2008 06:22:00 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2008/05/22/asp-net-web-services-and-jqueryajax/</guid>
		<description><![CDATA[As far as web developer&#8217;s go, I&#8217;ll freely admit that my Javascript is not one of my strong points.&#160; I don&#8217;t have a real good reason for this, it&#8217;s just that over the past few years I haven&#8217;t had much call/need to polish and hone my Javascript skills.&#160; Recently I discovered jQuery, and I must [...]]]></description>
			<content:encoded><![CDATA[<p>As far as web developer&#8217;s go, I&#8217;ll freely admit that my Javascript is not one of my strong points.&#160; I don&#8217;t have a real good reason for this, it&#8217;s just that over the past few years I haven&#8217;t had much call/need to polish and hone my Javascript skills.&#160; Recently I discovered <a href="http://www.jquery.com">jQuery</a>, and I must say that I wish I had know about this library earlier.&#160; The more I use <a href="http://www.jquery.com">jQuery</a>, the more I like it.&#160; The simple things are simple, and the hard things are possible.&#160; Take calling a simple webservice when the user clicks a button on a form.</p>
<p>Client side, the user would click on a button in their browser, in order to &quot;check out&quot; or &quot;check in&quot; &#8211; pretty simple stuff.&#160; Click a button, update a record in the database.&#160; I wanted this done via AJAX, as the page itself is pretty heavy with data, and I didn&#8217;t want to go through the whole page lifecycle.&#160; I spent some time Googling how to do this on the web, but I didn&#8217;t find anything that seemed to be suitable for something as simple as this.</p>
<p>So, enough boring stuff, on with the issue.&#160; In my current application the ASP.NET web service that the client should call looks something like:</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">[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">[ScriptService]
</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">public</span> <span style="color: #0000ff">class</span> CampaignProductCheckoutService : WebService, ICampaignProductCheckoutService
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  [WebMethod]
</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">public</span> <span style="color: #0000ff">void</span> CheckIn(<span style="color: #0000ff">int</span> campaignProductId, <span style="color: #0000ff">int</span> loginId)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  {
</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: #008000">// Do something...</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 style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  [WebMethod]
</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">public</span> <span style="color: #0000ff">void</span> CheckOut(<span style="color: #0000ff">int</span> campaignProductId, <span style="color: #0000ff">int</span> loginId)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  {
</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: #008000">// Do something...</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 style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">}</pre>
</pre>
<p>Pretty simple webservice, nothing fancy.&#160; Here is the corresponding Javascript on the browser:</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">$.ajax({
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  type: &quot;<span style="color: #8b0000">POST</span>&quot;,
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  url: &quot;<span style="color: #8b0000">CampaignProductCheckoutService.asmx/CheckOut</span>&quot;,
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  data: &quot;<span style="color: #8b0000">campaignProductId=3&amp;loginId=4</span>&quot;,
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  beforeSend: <span style="color: #0000ff">function</span>(xhr) {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    xhr.setRequestHeader(&quot;<span style="color: #8b0000">Content-Length</span>&quot;, &quot;<span style="color: #8b0000">campaignProductId=3&amp;loginId=4</span>&quot;.<span style="color: #0000ff">length</span>);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    $(&quot;<span style="color: #8b0000">#progressBarContainer</span>&quot;).show();
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  },
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  dataType: &quot;<span style="color: #8b0000">xml</span>&quot;,
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  complete: <span style="color: #0000ff">function</span> (xhr, msg) {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    $(&quot;<span style="color: #8b0000">#progressBarContainer</span>&quot;).hide();
</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">if</span> (xhr.<span style="color: #0000ff">status</span> == 200) {
</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">alert</span>(&quot;<span style="color: #8b0000">Happy Times!</span>&quot;);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</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">else</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">alert</span>(&quot;<span style="color: #8b0000">Wailing and gnashing of teeth!</span>&quot;);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">    }
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">  }
</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>This looks busy, but in reality, it isn&#8217;t. Now, for a detailed explanation of what is going on here, I&#8217;d suggest reading the book <a href="http://www.amazon.ca/gp/product/1933988355?ie=UTF8&amp;tag=opgenorthne08-20&amp;linkCode=as2&amp;camp=15121&amp;creative=330641&amp;creativeASIN=1933988355">jQuery in Action</a><img border="0" alt="" src="http://www.assoc-amazon.ca/e/ir?t=opgenorthne08-20&amp;l=as2&amp;o=15&amp;a=1933988355" width="1" height="1" />.&#160; It is a most helpful book for learning jQuery.</p>
<p>Anyway, here is a quick rundown of what is going on:&#160; the $.ajax is a jQuery method that will perform the AJAX call, using the parameters that we provide it.&#160; jQuery will perform an HTTP post to web service specified in url.&#160; As part of the POST request, you can see that we&#8217;re passing in the parameters for the webservice call.&#160; So far, pretty straightforward.</p>
<p>The next line, beforeSend, is a javascript method that jQuery will call before it does the POST.&#160; In this case, we make sure that the request header has the length of the data being sent, and we show a progress bar to the user.&#160; The funny syntax you see there is how we select the DIV element holding our animated gif and display it to the user.</p>
<p>Your standard ASP.NET web service will return XML to the client, and we inform jQuery of that with the dataType parameter.</p>
<p>By default, jQuery will perform the AJAX call asynchronously, so in the final line we provide another Javascript callback.&#160; jQuery will call this function once the request is finished.&#160; In this case, we hide the DIV element holding the progress bar, and we check the XMLHttpRequest object that is returned from jQuery. If the status is 200, then all okay and we display a happy message.&#160; Otherwise we assume the request failed, and display a sad message to the user. </p>
<p>There you have it, a quick and dirty explanation of using jQuery to call an ASP.NET Web Service.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2008/05/22/asp-net-web-services-and-jqueryajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ALT.NET Session #4: Sprocs Good Or Evil / NHibernate with Cartoon Bears</title>
		<link>http://www.opgenorth.net/2008/04/19/alt-net-session-4-sprocs-good-or-evil-nhibernate-with-cartoon-bears/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=alt-net-session-4-sprocs-good-or-evil-nhibernate-with-cartoon-bears</link>
		<comments>http://www.opgenorth.net/2008/04/19/alt-net-session-4-sprocs-good-or-evil-nhibernate-with-cartoon-bears/#comments</comments>
		<pubDate>Sun, 20 Apr 2008 01:25:00 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[ALT.NET]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2008/04/19/alt-net-session-4-sprocs-good-or-evil-nhibernate-with-cartoon-bears/</guid>
		<description><![CDATA[Two topics merged into one.&#160; Rod Paddock wants to talk about stored procs, and others want to learn how to explain NHibernate to other people who aren&#8217;t familiar with it (and minimize the jargon). Rod uses a custom code-gen solution based heavily on sprocs &#8211; a data driven approach.&#160; Sounds like it works well for [...]]]></description>
			<content:encoded><![CDATA[<p>Two topics merged into one.&#160; Rod Paddock wants to talk about stored procs, and others want to learn how to explain NHibernate to other people who aren&#8217;t familiar with it (and minimize the jargon).</p>
<p>Rod uses a custom code-gen solution based heavily on sprocs &#8211; a data driven approach.&#160; Sounds like it works well for him.&#160; Oren concurs that this technique could be very effective in certain circumstances.&#160; It will have problems with complex situations that deal with convoluted/difficult data scenarios.&#160; He&#8217;s giving an example, but I just can&#8217;t keep up with him.&#160; The point of Oren&#8217;s story is that a domain driven approach will would better when you&#8217;re not dealing with data but with data and behavior.</p>
<p>Brad Abrams brings up the point of noun centric vs. verb centric&#160; designs.&#160; Noun centric == data driven.&#160; Verb centric == domain driven.</p>
<p>Oren talks about one of the big advantages of DDD.&#160; We can very easily change the model, as it is all in code.&#160; Tools like R# allow us to make changes quickly, and then NHibernate will allow us to update the database just&#160; as quickly.&#160; Databases are an implementation detail, part of the application, a mere persistence store.&#160; A good domain design will generally lend itself to a&#160; decent database design.</p>
<p>Apparently it is possible to suffer from an SQL injection attack with NHibernate.&#160; According to Oren, you have to be pretty stupid for this to happen, but it can happen.&#160; I did not know this.</p>
<p>Topic changes:&#160; what do you do when you come to a client who has 1.5TB of established data and database.&#160; How do you deal with that?&#160; Ideally, you claim ownership of the data, and carry on.&#160; This isn&#8217;t very realistic.</p>
<p>Oren starts explaining that NHibernate can allow you to partition the data in existing databases to match your model.&#160; He suggests that it might be better to speak with the DBA to make a new model, as this approach might take a lot of effort.&#160; Might be smarter/better to change the persistence.</p>
<p>Oren&#8217;s preference is to generate the HBM&#8217;s by hand.&#160; He wants the pain to be real.&#160; The logic is that the pain will force you to thing about your model, and helps you focus on what is important to your model.&#160; By generating the code, you end up with, for example, a domain model that has 200 classes/tables and classes with 700 fields.</p>
<p>Another advantage of using NHibernate:&#160; you get a nice way to set up a unit of work, and can specify boundaries for your application.&#160; For example, you can, via an HttpModule with your unit of work, limit the number of queries (trips to the database).&#160; Oren:&#160; Going to the database is the best place to optimize, not the query itself.&#160; Minimize the trips to the database.&#160; You can enforce this limit right away.&#160; It is not a problem that will hit you out of the blue in production.</p>
<p>NHibernate is very complex, and the learning curve very steep.&#160; Oren argues it is not overly complex, and this complexity allows you to very advanced things.&#160; For the simple stuff, NHibernate is very easy.&#160; It is very irresponsible to just parachute in, introduce NHibernate, and then disappear.</p>
<p>Oren quotes: </p>
<ul>
<li>&quot;I tend to be nice to people that pay me&quot; </li>
<li>&quot;Use a set, that is all&quot; </li>
<li>&quot;Don&#8217;t worry about performance until you see you have a hotspot and are using a profiler&quot; </li>
<li>&quot;Whoever designed Linq bordered between genius and madman&quot; </li>
</ul>
<p><a href="http://www.flux88.com/">Ben Scheirman</a> refers us to <a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/collections.html">Chapter 6</a> in NHibernate.&#160; Important for collections.</p>
<p>It seems that this session is not so much stored procs, but a Q&amp;A session from the community about what exactly NHibernate can do.&#160; Oren&#8217;s knowledge and experience </p>
<p>The CLR is very fast, asserts Oren Eini.&#160; Rod Paddock disagrees.&#160; With WebForms, it isn&#8217;t the CLR that is slower, it is all the stuff that goes on behind the scenes with the page lifecycle.</p>
<p>The question is asked:&#160; Are datasets more efficient that NHibernate.&#160; Apparently some people get hung up on these types of things, and claim that tools like ORM&#8217;s aren&#8217;t good because they add overhead.&#160; Sounds like premature overhead to me.</p>
<p>Unrelated trivia:&#160; This is the latest in the year it has snowed in Seattle since 1968.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2008/04/19/alt-net-session-4-sprocs-good-or-evil-nhibernate-with-cartoon-bears/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mono.Rocks</title>
		<link>http://www.opgenorth.net/2007/12/20/mono-rocks/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mono-rocks</link>
		<comments>http://www.opgenorth.net/2007/12/20/mono-rocks/#comments</comments>
		<pubDate>Thu, 20 Dec 2007 07:38:00 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Mono]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[mono]]></category>

		<guid isPermaLink="false">http://www.opgenorth.net/2007/12/20/mono-rocks/</guid>
		<description><![CDATA[For those getting into .NET 3.5, you might find Mono.Rocks of interest.&#160; I first saw this on Jean-Baptiste Evain blog.&#160; Basically, this is a collection of extension methods for the class libraries.&#160; They are covered under the MIT licence, so you can pretty much use it anywhere.]]></description>
			<content:encoded><![CDATA[<p>For those getting into .NET 3.5, you might find <a href="http://www.mono-project.com/Rocks">Mono.Rocks</a> of interest.&#160; I first saw this on <a href="http://evain.net/blog/articles/2007/11/13/mono-rocks">Jean-Baptiste Evain blog</a>.&#160; Basically, this is a collection of extension methods for the class libraries.&#160; They are covered under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT licence</a>, so you can pretty much use it anywhere.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opgenorth.net/2007/12/20/mono-rocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
