<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Third Shelf &#187; .net</title>
	<atom:link href="http://thirdshelf.com/tag/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://thirdshelf.com</link>
	<description></description>
	<lastBuildDate>Sun, 13 May 2012 17:08:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='thirdshelf.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Third Shelf &#187; .net</title>
		<link>http://thirdshelf.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://thirdshelf.com/osd.xml" title="Third Shelf" />
	<atom:link rel='hub' href='http://thirdshelf.com/?pushpress=hub'/>
		<item>
		<title>Building a .NET application with Jenkins</title>
		<link>http://thirdshelf.com/2011/03/19/building-a-net-application-with-jenkins/</link>
		<comments>http://thirdshelf.com/2011/03/19/building-a-net-application-with-jenkins/#comments</comments>
		<pubDate>Sat, 19 Mar 2011 20:28:52 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[rants]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET MVC Framework]]></category>
		<category><![CDATA[Continuous integration]]></category>
		<category><![CDATA[Jenkins]]></category>
		<category><![CDATA[Microsoft Visual Studio]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=497</guid>
		<description><![CDATA[Building a .NET project using Jenkins CI is a true breeze&#8230; Jenkins configuration The first thing is to install the MsBuild Jenkins plugin. After that, it is a quick pointing to the msbuild executable and we&#8217;re off to a good start&#8230; Project configuration Next, configure the project to use the MsBuild version we setup. Point [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=497&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Building a .NET project using Jenkins CI is a true breeze&#8230;</p>
<p><strong>Jenkins configuration</strong></p>
<p>The first thing is to install the <a href="http://wiki.jenkins-ci.org/display/JENKINS/MSBuild+Plugin">MsBuild Jenkins plugin</a>. After that, it is a quick pointing to the msbuild executable and we&#8217;re off to a good start&#8230;</p>
<p><a href="http://thirdshelf.files.wordpress.com/2011/03/jenkins-msbuild-config.png"><img class="alignnone size-full wp-image-503" title="Jenkins-MsBuild-Config" src="http://thirdshelf.files.wordpress.com/2011/03/jenkins-msbuild-config.png?w=720" alt=""   /></a></p>
<p><strong>Project configuration</strong></p>
<p>Next, configure the project to use the MsBuild version we setup. Point it to your build file and we are ready to build&#8230;</p>
<p><a href="http://thirdshelf.files.wordpress.com/2011/03/jenkins-msbuild-project-config.png"><img class="alignnone size-full wp-image-504" title="Jenkins-MsBuild-Project-Config" src="http://thirdshelf.files.wordpress.com/2011/03/jenkins-msbuild-project-config.png?w=720" alt=""   /></a></p>
<p><strong>The fairy tale</strong></p>
<p>In theory, of course, that is how simple it should have been. At least, that&#8217;s how the fairy tale goes. Having a look at the console output and <em>bam</em>, back to the cruel world where I find myself with a couple of challenges:</p>
<ol>
<li>warning MSB3644: The reference assemblies for framework &#8220;.NETFramework,Version=v4.0&#8243; were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.</li>
<li>error MSB4019: The imported project &#8220;C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets&#8221; was not found. Confirm that the path in the &lt;Import&gt; declaration is correct, and that the file exists on disk.</li>
<li>error CS0234: The type or namespace name &#8216;Mvc&#8217; does not exist in the namespace &#8216;System.Web&#8217; (are you missing an assembly reference?)</li>
</ol>
<p><strong>The fixing</strong></p>
<p>The &nbsp;first issue is relatively simple to fix. It requires that you download and install the small (~500MB) <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=35aeda01-421d-4ba5-b44b-543dc8c33a20&amp;displaylang=en">Windows SDK for Windows 7 and .NET Framework 4</a>. You don&#8217;t need all of it. Only select the .NET Development components in the installation options. Install this on the server and the warnings be gone!</p>
<p>The second, yeah, the second issue is where the Caption Hook catches something unmentionable. To fix this; you&#8217;ll feel the hook&#8230; Two choices; either create the folders and copy the missing file from your development machine or install Visual Studio on the build server. The purist rants and raves. Go with the lesser of the two evils, create the folder structure and copy the file. That wasn&#8217;t that painful; I feel dirty.</p>
<p>The third issue is that ASP.NET MVC 3 is not found anywhere on the server. Easy fix, <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d2928bc1-f48c-4e95-a064-2a455a22c8f6&amp;displaylang=en">download and install ASP.NET MVC 3</a>.</p>
<p>Finally, the project builds and all is well. For now.</p>
<p>by <a title="Sydney" rel="author" href="http://thirdshelf.com/about/">Sydney du Plooy</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/497/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=497&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2011/03/19/building-a-net-application-with-jenkins/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2011/03/jenkins-msbuild-config.png" medium="image">
			<media:title type="html">Jenkins-MsBuild-Config</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2011/03/jenkins-msbuild-project-config.png" medium="image">
			<media:title type="html">Jenkins-MsBuild-Project-Config</media:title>
		</media:content>
	</item>
		<item>
		<title>Git and Hudson Brothers</title>
		<link>http://thirdshelf.com/2011/03/10/git-and-hudson-brothers/</link>
		<comments>http://thirdshelf.com/2011/03/10/git-and-hudson-brothers/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 19:04:55 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[reviews]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[hudson]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[msysgit]]></category>
		<category><![CDATA[Revision control]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=462</guid>
		<description><![CDATA[For a while now, I&#8217;ve been thinking about creating a source control and build server for a couple of projects that I&#8217;m working on. I&#8217;ll admit, I moonlight. Anyway, a great analysis ensued. Starting with the OS; what will it be, what does it need to be? Considering that I&#8217;m building .NET projects and they&#8217;re Windows [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=462&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://thirdshelf.files.wordpress.com/2011/03/hudson-watermark.png"><img class="size-full wp-image-470 alignright" title="Hudson-Watermark" src="http://thirdshelf.files.wordpress.com/2011/03/hudson-watermark.png?w=720" alt=""   /></a>For a while now, I&#8217;ve been thinking about creating a <a href="http://en.wikipedia.org/wiki/Source_control">source control</a> and <a href="http://en.wikipedia.org/wiki/Continuous_integration">build server</a> for a couple of projects that I&#8217;m working on. I&#8217;ll admit, I moonlight. Anyway, a great analysis ensued. Starting with the OS; what will it be, what does it need to be? Considering that I&#8217;m building .NET projects and they&#8217;re Windows based; well that kind of settles that. Next up, which source control system? Oh boy, this took a while&#8230;</p>
<h3>Source Control</h3>
<p>Since everyone, OK, almost everyone, raves about <a href="http://en.wikipedia.org/wiki/Git_(software)">Git</a>, I suppose I&#8217;ll have to succumb. But, this is where the fun starts. I want Git, I want Windows. <a href="http://www.kernel.org/pub/software/scm/git/docs/git-push.html">Pushing</a>, <a href="http://www.kernel.org/pub/software/scm/git/docs/git-clone.html">cloning</a> and so on is what really I want. What a painful story&#8230; This requires the installation of <a href="http://code.google.com/p/msysgit/">MSysGit</a> or <a href="http://www.cygwin.com">Cygwin </a>and some <a href="http://en.wikipedia.org/wiki/Secure_Shell">SSH server</a>, blah blah, whatever. It was simply too much.</p>
<p>I decided to run <a href="http://www.visualsvn.com/">VisualSVN </a>on the server and then use <a href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git-svn</a> to bridge that little dilemma. Well, that kinda sucked. After formatting and configuring and formatting and configuring, I finally found<a href="http://www.jeremyskinner.co.uk/2010/06/25/hosting-a-git-server-under-iis7-on-windows/" target="_blank"> this post by Jeremy Skinner</a>. It explains how to setup Git on Windows using IIS 7.0, without any other fancy installations and configurations. He calls it <a href="https://github.com/JeremySkinner/git-dot-aspx/downloads" target="_blank">git-dot-aspx (GitAspx)</a>. To my surprise, this worked elegantly, the first time. Push, pull and clone without any issues. Great.</p>
<h3>Continuous Integration</h3>
<p>What a mental battle this turned out to be! What should I use, what do I need to use? There is from <a href="http://sourceforge.net/projects/ccnet/" target="_blank">CruiseControl.NET</a> to <a href="http://hudson-ci.org/" target="_blank">Hudson</a>. A colleague mentioned Hudson and, being quite popular, I decided to investigate. This turned out to be a fantastic piece of software. It is a Java application, but I decided that it is well worth it. One click and it installs as a Windows service. One command line and it uninstalls cleanly. Unbelievable! Such a polished product. Also, it has many plugins from MsBuild to Git to Twitter. Talk about pressure, having your build status published to Twitter!</p>
<p>For a good Windows alternative, these two products turned out to be highly effective and user friendly.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/462/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=462&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2011/03/10/git-and-hudson-brothers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2011/03/hudson-watermark.png" medium="image">
			<media:title type="html">Hudson-Watermark</media:title>
		</media:content>
	</item>
		<item>
		<title>AutoMocking with RhinoMocks and StructureMap</title>
		<link>http://thirdshelf.com/2010/12/13/automocking-with-rhinomocks-and-structuremap/</link>
		<comments>http://thirdshelf.com/2010/12/13/automocking-with-rhinomocks-and-structuremap/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 15:04:25 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=451</guid>
		<description><![CDATA[Auto mocking is the process whereby mock objects are created and injected into an object. By using this technique we relieve ourselves from the burden of creating and injecting mocks manually. Consider the following test class that requires two dependencies; namely, IPropertyDependency and IConstructorDependency: The one dependency is provided in the constructor and the other is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=451&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/02/09/automocker-in-structuremap-2-5.aspx">Auto mocking</a> is the process whereby mock objects are created and injected into an object. By using this technique we relieve ourselves from the burden of creating and injecting mocks manually. Consider the following test class that requires two dependencies; namely, IPropertyDependency and IConstructorDependency:</p>
<p><pre class="brush: csharp;">
public class ClassToBeAutoMocked
{
	private IConstructorDependency _ConstructorInjectedDependency;

	public ClassToBeAutoMocked(IConstructorDependency dep)
	{
		_ConstructorInjectedDependency = dep;
	}

	private IPropertyDependency PropertyDependency
	{
		get;
		set;
	}

	public string PrintConstructorDependency()
	{
		return _ConstructorInjectedDependency.Print();
	}

	public string PrintPropertyDependency()
	{
		return PropertyDependency.Print();
	}
}
</pre></p>
<p>The one dependency is provided in the constructor and the other is injected via the private property. Out-of-the-box, StructureMap AutoMocker provides the ability to mock and inject the constructor dependency. Private properties, however, are not supported. This can be solved by means of an <a href="http://blogs.planbsoftware.co.nz/?p=291">extension method applied to the RhinoAutoMocker type</a>, for example:</p>
<p><pre class="brush: csharp;">
public static class RhinoAutoMockerExtensions
{
	public static void RegisterPropertyDependency&lt;TARGETCLASS&gt;(this RhinoAutoMocker autoMocker, string propertyName) where TARGETCLASS : class
	{
		var propertyInfo = typeof(TARGETCLASS).GetProperty(propertyName,
			BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

		if (propertyInfo == null)
		{
			throw new ArgumentException(string.Format(&quot;Property {0} was not found on the type {1}&quot;,
				propertyName, typeof(TARGETCLASS).Name));
		}

		var propertyType = propertyInfo.PropertyType;
		var mockDependency = MockRepository.GenerateMock(propertyType, null);
		autoMocker.Inject(propertyType, mockDependency);
		propertyInfo.SetValue(autoMocker.ClassUnderTest, mockDependency, null);
	}
}
</pre></p>
<p>We now have the necessary pieces to get an auto mocked instance of ClassToBeAutoMocked.</p>
<p>Next, create an instance of the RhinoAutoMocker class with the concrete type, which will then create the constructor dependency mock and inject it. Because the private property dependency injection is not supported we have to tell the AutoMocker that we want the private property mocked and injected as well. We accomplish this by calling the extension method RegisterPropertyDependency with the name of the property that must be mocked. To obtain a reference to the generated mock we can call the Get method with the dependency type which will return the mock instance. We are then free to stub or set expectations on that dependency as required by our unit tests.</p>
<p>For example:</p>
<p><pre class="brush: csharp;">
static void Main(string[] args)
{
	var mocks = new RhinoAutoMocker(MockMode.AAA);
	mocks.RegisterPropertyDependency(&quot;PropertyDependency&quot;);

	mocks.Get&lt;IConstructorDependency&gt;().Stub(x =&gt; x.Print()).Return(&quot;On fire with the constructor dependency!&quot;);
	mocks.Get&lt;IPropertyDependency&gt;().Stub(x =&gt; x.Print()).Return(&quot;On fire with the property dependency!&quot;);

	Console.WriteLine(&quot;Constructor dependency output: {0}&quot;, mocks.ClassUnderTest.PrintConstructorDependency());
	Console.WriteLine(&quot;Property dependency output: {0}&quot;, mocks.ClassUnderTest.PrintPropertyDependency());

	Console.ReadLine();
}
</pre></p>
<div id="_mcePaste" class="mcePaste" style="position:absolute;left:-10000px;top:749px;width:1px;height:1px;">
<pre style="font:normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">IConstructorDependency</pre>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/451/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/451/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/451/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/451/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/451/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/451/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/451/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/451/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/451/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/451/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/451/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/451/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/451/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/451/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=451&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2010/12/13/automocking-with-rhinomocks-and-structuremap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>
	</item>
		<item>
		<title>Mocking multiple interfaces using Rhino Mocks</title>
		<link>http://thirdshelf.com/2010/06/06/mocking-multiple-interfaces-using-rhino-mocks/</link>
		<comments>http://thirdshelf.com/2010/06/06/mocking-multiple-interfaces-using-rhino-mocks/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 18:03:00 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[rhino-mocks]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=393</guid>
		<description><![CDATA[A while back on StackOverflow I asked a question on how to create a mock object with Rhino Mocks that implements multiple interfaces. In other words, I want to generate a mock that implements more than one interface. This baffled me for a while and I was shown the light by one of my colleagues. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=393&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A while back on StackOverflow I <a href="http://stackoverflow.com/questions/503263/how-to-determine-if-a-type-implements-a-specific-generic-interface-type">asked a question</a> on how to create a <a href="http://en.wikipedia.org/wiki/Mock_object">mock object</a> with <a href="http://www.ayende.com/projects/rhino-mocks.aspx">Rhino Mocks</a> that implements multiple interfaces. In other words, I want to generate a mock that implements more than one interface. This baffled me for a while and I was shown the light by one of my colleagues.</p>
<p>A multi-mock is created like so:</p>
<p><pre class="brush: csharp;">
var mocker = new MockRepository();
var mock = mocker.CreateMultiMock&lt;IPrimaryInterface&gt;(typeof(IFoo), typeof(IBar));
mock.Expect(x =&gt; x.AnswerToUniverse()).Return(42);
mocker.ReplayAll();
</pre><br />
Note the call to ReplayAll. Without this call the mock will not be setup with the intended values.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/393/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=393&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2010/06/06/mocking-multiple-interfaces-using-rhino-mocks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>
	</item>
		<item>
		<title>XML Intellisense for NHibernate</title>
		<link>http://thirdshelf.com/2009/05/16/xml-intellisense-for-nhibernate/</link>
		<comments>http://thirdshelf.com/2009/05/16/xml-intellisense-for-nhibernate/#comments</comments>
		<pubDate>Sat, 16 May 2009 13:46:19 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[nhibernate]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=227</guid>
		<description><![CDATA[Using NHibernate requires the writing of some tedious XML-based configuration mapping files. Remembering all the tags and attributes can sometimes be overwhelming. Thankfully the contributors decided to include intellisense hints, which are in nhibernate-configuration.xsd and nhibernate-mapping.xsd. In order to have the hints available in Visual Studio 2008 copy the files into C:\Program Files\Microsoft Visual Studio [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=227&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-230" title="nhibernate-intellisense" src="http://thirdshelf.files.wordpress.com/2009/05/nhibernate-intellisense.jpg?w=720" alt="nhibernate-intellisense"   />Using <a href="http://nhforge.org/">NHibernate</a> requires the writing of some tedious XML-based configuration mapping files. Remembering all the tags and attributes can sometimes be overwhelming. Thankfully the contributors decided to include intellisense hints, which are in <strong>nhibernate-configuration.xsd</strong> and <strong>nhibernate-mapping.xsd</strong>.</p>
<p>In order to have the hints available in Visual Studio 2008 copy the files into <em>C:\Program Files\Microsoft Visual Studio 9.0\XML\Schemas</em> and restart Visual Studio.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/227/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=227&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2009/05/16/xml-intellisense-for-nhibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2009/05/nhibernate-intellisense.jpg" medium="image">
			<media:title type="html">nhibernate-intellisense</media:title>
		</media:content>
	</item>
		<item>
		<title>Dynamic type factory</title>
		<link>http://thirdshelf.com/2008/06/01/dynamic-type-factory/</link>
		<comments>http://thirdshelf.com/2008/06/01/dynamic-type-factory/#comments</comments>
		<pubDate>Sun, 01 Jun 2008 17:33:38 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[aop]]></category>

		<guid isPermaLink="false">http://thirdshelf.wordpress.com/?p=25</guid>
		<description><![CDATA[Wow, it has been crazy for a while, but I finally got it together :). So, on with our little aspect oriented framework. The first building block in our aspect proxy framework is the Dynamic Type Factory. As you might have guessed, this is the component that we will use to define a dynamic assembly [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=25&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Wow, it has been crazy for a while, but I finally got it together :). So, on with our little aspect oriented framework.</p>
<p>The first building block in our aspect proxy framework is the Dynamic Type Factory. As you might have guessed, this is the component that we will use to define a dynamic assembly that will hold our in-memory assembly with the dynamically created types. In other words, we have an assembly that is created in-memory as a container for the proxy classes that we will create and instantiate.</p>
<p>A couple of static variables and constants are needed for the DynamicTypeFactory class which are:<br />
<pre class="brush: csharp;">
private const string ASSEMBLY_NAME = &quot;AspectProxies&quot;;

private static ModuleBuilder _ModuleBuilder;
private static AssemblyBuilder _AssemblyBuilder;

private static string _FileName = 
  string.Format(&quot;{0}.dll&quot;, ASSEMBLY_NAME);

private static AssemblyName _AssemblyName = 
  new AssemblyName(ASSEMBLY_NAME);
</pre><br />
First of all, we need to give the assembly some sort of name and I thought &#8220;AspectProxies&#8221; to be a good fit. We then declare an AssemblyBuilder which we will use only to define  a dynamic module. We then declare a ModuleBuilder which we will use to define our dynamic types with. We set a FileName variable which we will expose via a property so that others can know what the assembly file is called when it saved to disk. Lastly we declare an AssemlyName variable that we will provide to the AssemblyBuilder.</p>
<p>For simplicity we will only have one dynamic assembly in the current AppDomain. Hence, the DynamicTypeFactory class will have a static constructor that creates a new dynamic assembly and module, like so:<br />
<pre class="brush: csharp;">
static DynamicTypeFactory()
{
  _AssemblyBuilder = Thread.GetDomain().DefineDynamicAssembly(
    _AssemblyName, AssemblyBuilderAccess.RunAndSave);

  _ModuleBuilder = _AssemblyBuilder.DefineDynamicModule(
    ASSEMBLY_NAME, _FileName);
}
</pre><br />
We then create a property to expose our filename, like so:<br />
<pre class="brush: csharp;">
public static string FileName
{
  get { return _FileName; }
}
</pre><br />
Next, we define the most commonly used method in this class, that we will call to define our dynamic types with:<br />
<pre class="brush: csharp;">
public static TypeBuilder Create&lt;T&gt;(T instance, string identifier)
{
  if (!typeof(T).IsInterface)
    throw new ArgumentException(&quot;Type T must be an interface.&quot;);

  if (instance == null)
    throw new ArgumentNullException(&quot;instance&quot;));

  if (string.IsNullOrEmpty(identifier))
    identifier = Guid.NewGuid().ToString(&quot;N&quot;);

  return _ModuleBuilder.DefineType(
    string.Format(&quot;{0}_Proxy&quot;, identifier),
    TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.Sealed,
    typeof(object),
    Resolver.GetInterfaces(instance.GetType()));
}
</pre><br />
In this method we firstly check whether the type of T is indeed an interface, since we only want to create proxy types for interfaces. We also check that the instance that we were provided with is not null. The reason we need to check this is that we are going to find all of the interfaces that the instance implements, since the interface might not necessarily inherit from the same interfaces.</p>
<p>Obviously, every type that we define must have a unique name and this is where the identifier comes in. Sometimes we would want a name that we can recognize such as the type the proxy is for and maybe some of the interfaces. Using reflector to examine our types can become rather painful to examine if we have a thousand types and no way to identify them. Just for safety we check if we an identifier, if not then we will just assign it a GUID value. This identifier is later on post-pended with &#8220;_Proxy&#8221;.</p>
<p>The next bit actually defines the type in the dynamic module. We supply a couple of attributes that says that our type must be a public sealed class which derives from object. The next parameter resolves or gets all of the interfaces on our instance and supplies them for the type definition. Now we defined a type in the meta data but still need to give this type a body.</p>
<p>When debugging, it is useful to have the ability to save the proxy type to the disk. For that we need to have a method like so:<br />
<pre class="brush: csharp;">
public static void Save()
{
  _AssemblyBuilder.Save(_FileName);
}
</pre><br />
Now that we are able to define types dynamically we will next look at how to create the body of for this proxy type.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirdshelf.wordpress.com/25/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirdshelf.wordpress.com/25/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=25&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2008/06/01/dynamic-type-factory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>
	</item>
		<item>
		<title>Proxy class design</title>
		<link>http://thirdshelf.com/2008/04/20/proxy-class-design/</link>
		<comments>http://thirdshelf.com/2008/04/20/proxy-class-design/#comments</comments>
		<pubDate>Sun, 20 Apr 2008 18:14:01 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[aop]]></category>

		<guid isPermaLink="false">http://thirdshelf.wordpress.com/?p=24</guid>
		<description><![CDATA[As part of designing our AOP.NET framework, I thought it best to start with the end in mind. What that entails is to figure out what our proxy class should look like. Let&#8217;s start with a simple interface and then design the proxy class according to the interface. If only all things in life could [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=24&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As part of designing our AOP.NET framework, I thought it best to start with the end in mind. What that entails is to figure out what our proxy class should look like. Let&#8217;s start with a simple interface and then design the proxy class according to the interface.</p>
<p><pre class="brush: csharp;">
public interface IVehicle
{
  string Make{get;set;}
  void Start();
  void Stop();
}
</pre><br />
If only all things in life could be so simple. What do we expect from our proxy class? First of all, it should proxy the call to the target instance.</p>
<p>But before the call is made to the target instance, it should first call our aspect class. Assume, for now, that our aspect just logs an entry whenever a call is made to one of the members.</p>
<p>That means that we would expect our proxy class to look something like this:<br />
<pre class="brush: csharp;">
[Proxy]
public sealed class IVehicle_LogAspect_Proxy : IVehicle
{
  private IVehicle _TargetInstance;
  private ILoggerAspect _LoggerAspect;

  public IVehicle_LogAspect_Proxy(
    IVehicle targetInstance, ILoggerAspect loggerAspect)
  {
    _TargetInstance = targetInstance;
    _LoggerAspect = loggerAspect;
  }

  public string Make
  {
    get
    {
      _LoggerAspect.Log(&quot;Make.Get&quot;);
      return _TargetInstance.Make;
    }
    set
    {
      _LoggerAspect.Log(&quot;Make.Set&quot;);
      _TargetInstance.Make = value;
    }
  }

  public void Start()
  {
    _LoggerAspect.Log(&quot;Start&quot;);
    _TargetInstance.Start();
  }

  public void Stop()
  {
    _LoggerAspect.Log(&quot;Stop&quot;);
    _TargetInstance.Stop();
  }
}
</pre></p>
<p>First, there is a Proxy attribute applied to the proxy class. This is just to identify the class as a proxy type. Sometimes it might be necessary for calling code to know whether it is dealing with a real object or a proxy. The attribute facilitates this quite nicely.</p>
<p>Naming the type is a matter of concatenating the interface names, separated by underscores together with the aspect that is injected. Finally, we simply just add the word Proxy to the type name to help with identification.</p>
<p>After all that the constructor is next. The constructor plays a vital role in the proxy as it receives the reference to the target instance as well as the reference to the aspect instance. Both these references are assigned to private variables by the constructor.</p>
<p>As you can see, the aspect method is directly injected into the member, before the call is passed to the target instance.</p>
<p>The advantages of doing it this way are that all the heavy aspect code is outside of the proxy class, which makes it a lot simpler to write and maintain.</p>
<p>Now that we have an idea of what the proxy class should look like we will <a href="http://thirdshelf.com/2008/06/01/dynamic-type-factorydynamic-type-factory/">next</a> look at the framework building blocks.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirdshelf.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirdshelf.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=24&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2008/04/20/proxy-class-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>
	</item>
		<item>
		<title>Proxy aspect requirements</title>
		<link>http://thirdshelf.com/2008/04/02/proxy-aspect-requirements/</link>
		<comments>http://thirdshelf.com/2008/04/02/proxy-aspect-requirements/#comments</comments>
		<pubDate>Wed, 02 Apr 2008 17:53:37 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[aop]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=15</guid>
		<description><![CDATA[Problem: A business software package has cross-cutting functionality across its domain objects. This leads to duplicated code and needs to be generalised. Solution: Produce a general proxy aspect framework for applying aspects to domain objects. Note: The framework that we are going to construct is for a specific scenario and is not intended to compete [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=15&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Problem: </strong></p>
<p>A business software package has cross-cutting functionality across its <a href="http://en.wikipedia.org/wiki/Domain_object" target="_blank">domain objects</a>. This leads to duplicated code and needs to be generalised.</p>
<p><strong>Solution: </strong></p>
<p>Produce a general proxy aspect framework for applying aspects to domain objects.</p>
<p>Note: The framework that we are going to construct is for a specific scenario and is not intended to compete with other aspect oriented frameworks out there. It is intended to demonstrate the principles and considerations that need to be taken into account when applying aspects to domain objects.</p>
<p><strong>Prerequisite:</strong></p>
<p>Every domain object must be defined by an <a href="http://en.wikipedia.org/wiki/Interface_(computer_science)" target="_blank">interface</a>.</p>
<p><strong>Requirements:</strong></p>
<p>At a high level our requirements for the proxy aspect framework are as follows:</p>
<ul type="disc">
<li>Support multiple aspects per domain object;</li>
<li>Generated proxy must at least implement the domain objects      interface;</li>
<li>Support aspects that need to implement their own interfaces on the proxy;</li>
<li>Collections must be applied the same aspects as the domain      object it is defined on;</li>
<li>Proxy types must be <a href="http://en.wikipedia.org/wiki/Cache" target="_blank">cached</a>;</li>
<li>Support the ability to place intercepting calls before and/or      after the call to the target instance;</li>
<li>Must be able to save the assembly containing all proxy types;</li>
<li>Must be able to intercept methods, events and properties.</li>
</ul>
<p><a href="http://thirdshelf.com/2008/04/20/proxy-class-design/" target="_blank">Next</a>, we will discuss the framework design.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirdshelf.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirdshelf.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=15&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2008/04/02/proxy-aspect-requirements/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>
	</item>
		<item>
		<title>Proxy aspect oriented approach</title>
		<link>http://thirdshelf.com/2008/03/27/proxy-aspect-oriented-approach/</link>
		<comments>http://thirdshelf.com/2008/03/27/proxy-aspect-oriented-approach/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 18:08:36 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[aop]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=9</guid>
		<description><![CDATA[A proxy aspect approach is one of many approaches in Aspect Oriented Programming. The general idea behind AOP is to deal with the problem of cross-cutting concerns. Let’s say you want to check the permissions of a user before executing a method (this is the type of aspect that we want to apply to our [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=9&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal"><span>A proxy aspect approach is one of many approaches in <a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">Aspect Oriented Programming</a>. The general idea behind AOP is to deal with the problem of <a href="http://en.wikipedia.org/wiki/Cross-cutting_concern">cross-cutting concerns</a>. </span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span>Let’s say you want to check the permissions of a user before executing a method (this is the type of aspect that we want to apply to our object). You can appreciate that when a system is beyond “Hello World!” that this can turn out to be quite a thing to remember and apply on every method.</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span>To solve this problem we would need to inject this call into the methods where this security check needs to be done. This can be done in various ways, such as creating a proxy at runtime that performs the check or alter the assemblies with another tool afte</span><span>r compilation.</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span>Over the next couple of weeks, I will walk you through the requirements, design and construction of one of these approaches that I call; you guessed it; the proxy aspect approach.</span></p>
<p class="MsoNormal"><span> </span></p>
<p><img src="http://thirdshelf.files.wordpress.com/2008/03/proxyandtarget.png?w=720" alt="Target instance with Proxy object" align="left" /><span>At a high level, the idea is to create a <a href="http://en.wikipedia.org/wiki/Proxy_pattern" target="_blank">proxy</a> for every object that needs to have certain functionality executed as soon as, for example, a method is entered or a property is changed. In effect, the object will have multiple layers or proxies to which all calls; that are intended for the target instance; are directed. </span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span>One proxy is created</span><span> for each aspect that is applied, and every proxy object carries a reference to the instance of the target instance. This target instance can either be another proxy object or</span><span> the final domain object, say.</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span>When the call is made to the proxy object it will execute the aspect code and then forward the call to the target instance. If the target instance is a proxy, the same process will happen again until it reaches the inner most target instance where the call is finally handled. If there are results that need to be returned, it passes back up through every proxy until it reaches the original caller.</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span><a href="http://thirdshelf.com/2008/04/02/proxy-aspect-requirements/" target="_blank">Next</a>, we’ll have a look at the requirements.</span></p>
<p class="MsoNormal">
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirdshelf.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirdshelf.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=9&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2008/03/27/proxy-aspect-oriented-approach/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2008/03/proxyandtarget.png" medium="image">
			<media:title type="html">Target instance with Proxy object</media:title>
		</media:content>
	</item>
	</channel>
</rss>
