<?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>pushbomb &#187; reflection</title>
	<atom:link href="http://team.pushbomb.com/category/concepts-implemented/reflection/feed/" rel="self" type="application/rss+xml" />
	<link>http://team.pushbomb.com</link>
	<description>tv programmed by the collective</description>
	<lastBuildDate>Tue, 05 Jan 2010 22:49:48 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='team.pushbomb.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/a08732ed34e6814d5a5513fe8cde5696?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>pushbomb &#187; reflection</title>
		<link>http://team.pushbomb.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://team.pushbomb.com/osd.xml" title="pushbomb" />
	<atom:link rel='hub' href='http://team.pushbomb.com/?pushpress=hub'/>
		<item>
		<title>Advanced C# 3.0: Part 3 &#8211; New Language Features as &#8216;Domain Specific&#8217; as well as General Purpose Extensions</title>
		<link>http://team.pushbomb.com/2008/05/27/advanced-c-30-part-3-new-language-features-as-domain-specific-as-well-as-general-purpose-extensions/</link>
		<comments>http://team.pushbomb.com/2008/05/27/advanced-c-30-part-3-new-language-features-as-domain-specific-as-well-as-general-purpose-extensions/#comments</comments>
		<pubDate>Tue, 27 May 2008 22:42:46 +0000</pubDate>
		<dc:creator>Damon Wilder Carr</dc:creator>
				<category><![CDATA[C# 3.0 Enhancements]]></category>
		<category><![CDATA[C# 3.0 for Internal DSL]]></category>
		<category><![CDATA[Framework Design]]></category>
		<category><![CDATA[Proof Driven Development]]></category>
		<category><![CDATA[Software Design]]></category>
		<category><![CDATA[Software Futures]]></category>
		<category><![CDATA[agile practices]]></category>
		<category><![CDATA[reflection]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[dsl]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[GAT]]></category>
		<category><![CDATA[Resharper]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://dcarr.wordpress.com/2008/05/27/advanced-c-30-part-3-new-language-features-as-domain-specific-as-well-as-general-purpose-extensions/</guid>
		<description><![CDATA[One of the compelling directions beyond 'the basics' of domain-driven development is the advent and increasing use of 'DSL' (Domain Specific Language) technology in .NET. We have had a rich set of features since the 2005 release of Visual Studio in the Guidance Automation Toolkit and the DSL Toolkit and these have become even more compelling. However for some needs, the language now may provide enough for many smaller cases.

Now that new .NET 3.5 C# 3.0 features are allowing us to make the Framework API of .NET work in ways not present 'out of the box' the scope of what is possible can be deep and broad.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=team.pushbomb.com&blog=2366446&post=238&subd=dcarr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>One of the compelling directions beyond &#8216;the basics&#8217; of domain-driven development is the advent and increasing use of &#8216;DSL&#8217; (Domain Specific Language) technology in .NET. We have had a rich set of features since the 2005 release of Visual Studio in the <a href="http://msdn.microsoft.com/en-us/vsx/default.aspx">Guidance Automation Toolkit</a> and the <a href="http://msdn.microsoft.com/en-us/library/bb126235.aspx">DSL Toolkit</a> and these have become even more compelling. I wrote about this back in January, 2006 <a href="http://www.developerland.com/DotNet/Design/444.aspx">as published here</a>. However for some needs, the language now may provide enough for many smaller cases.</p>
<blockquote><p align="center">Keep in mind, this post is not focused on DSL topics (one any developer cannot really afford to miss now), so one could debate the merits of the link I make. My argument is this:</p>
<p align="center">My definition of a DSL is very simply :</p>
</blockquote>
<p>A Domain Specific Language is a way, typically using a combination of visual and textual methods, or just textual, to solve a limited but typically non-trivial set of problems. It is typically a smaller stand-alone &#8216;language&#8217; or language-extension to a larger more horizontal language such as C# (the point I make here is C# has evolved to allow you to expand C# with DSLs you write in C#. This is very different the the DSL Toolkit and I have never had this opinion until I finally got to be immersed deeply in functional style programming enhancements to C# and the ease of extending just about any API with extensions..</p>
<p><a href="http://damon.agilefactor.com/domain-specific-languages-central-to-staying-relevant/">I continue the discussion of what a DSL is here.</a> I will be adding to this section of the site over time but if you just want the listed info, no need to go on a tangent now.</p>
<blockquote><p><strong>Now that new .NET 3.5 C# 3.0 features are allowing us to make the Framework API of .NET work in ways not present &#8216;out of the box&#8217; the scope of what is possible can be deep and broad.</strong></p>
</blockquote>
<h2>Part 1 : The DSL Perspective &#8211; A Real Example</h2>
<p>I&#8217;ll use a project we are working on now, which is quite specifically aimed to</p>
<ul>
<li>Minimize the configuration overhead of using an Inversion of Control container </li>
<li>Provide the benefit of &#8216;provider/container&#8217; independence </li>
<li>Allow the consumer to change &#8216;container provider&#8217; vendors with a simple change in &#8216;meta configuration&#8217; </li>
</ul>
<p>In other words, we are trying to create an abstraction on top of an abstraction, as we believe this particular area is now mature enough (and indeed this is how software engineering historically more then not progresses over time) to do so.</p>
<p>This project has no intention of BEING an inversion of control container nor a dependency injector, rather its aim is to allow people to make use of these critical concepts in much easier ways while eliminating hesitation related to provider lock-in.</p>
<p>It&#8217;s no secret we are massive fans of the work of the <a href="http://www.castleproject.org/">Castle Project</a> and they are indeed the first &#8216;plug-in&#8217; adapter we are on schedule to deliver. However the architecture (something this post is NOT trying to explain) of our solution models the DOMAIN of this area, and is not specific to any particular offering (although to be blunt I would say if any bias existed it would be from the conceptual framework that exists now in the <a href="http://www.castleproject.org/container/index.html">Windsor Container/MicroKernal trunk</a>).</p>
<h4>A domain specific example</h4>
<p>In the area of ASP.NET one technique for loading our solution into memory is via the IHttpModule implementation we provide. Here is what the custom global.asax.cs code looks like:</p>
<p><span style="background:black 0 50%;color:#9bdd22;">public abstract class </span><span style="background:black 0 50%;color:#8bcfe2;">IntegrationPoint </span><span style="background:black 0 50%;color:#feba1b;">: </span><span style="background:black 0 50%;color:#8bcfe2;">HttpApplication</span><span style="background:black 0 50%;color:#feba1b;">, </span><span style="background:black 0 50%;color:#2b91af;">IDomainApplication </span><span style="background:black 0 50%;color:#feba1b;">{ </span></p>
<p><span style="background:black 0 50%;color:#9bdd22;">private static </span><span style="background:black 0 50%;color:#2b91af;">IZeroConfigDI </span><span style="background:black 0 50%;color:#feba1b;">_container; </span></p>
<p><span style="background:black 0 50%;color:#808080;">/// &lt;summary&gt;      <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">Executes custom initialization code after      <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">all event handler      <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">modules have been added.      <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">Also acquire a reference to the HttpModule      <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">for IoC / DI if present as a module      <br /></span><span style="background:black 0 50%;color:#808080;">/// &lt;/summary&gt;      <br />&#160;</span><span style="background:black 0 50%;color:#9bdd22;">public override void </span><span style="background:black 0 50%;color:#feba1b;">Init() {<span style="background:black 0 50%;color:#feba1b;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>
<div><span style="background:black 0 50%;color:#feba1b;"><span style="background:black 0 50%;color:#feba1b;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; _container = Modules.GetIoCModule(); </span></span></div>
<div><span style="background:black 0 50%;color:#feba1b;"><span style="background:black 0 50%;color:#feba1b;">&#160;&#160;&#160;&#160;&#160; </span></span><span style="background:black 0 50%;color:#9bdd22;">&#160;&#160;&#160; base</span><span style="background:black 0 50%;color:#feba1b;">.Init();</span></div>
<div><span style="background:black 0 50%;color:#feba1b;"></span></div>
<div><span style="background:black 0 50%;color:#feba1b;"><span style="background:black 0 50%;color:#feba1b;">} </span></span>
</p></div>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>The interesting areas which are not provided by Microsoft include:</p>
<ol>
<li>IDomainApplication interface </li>
<li>IZeriConfigDI Interface static reference </li>
<li>Modules.GetIoCModule() </li>
</ol>
<p>The first two have more to do with our solution then the topic of this post, so I&#8217;ll focus on #3.</p>
<p>As this code is inside the HttpApplication, we have access to the Modules property which is read-only. Here is the documentation:</p>
<p>&#160;</p>
<table cellspacing="10" cellpadding="10" width="648" border="1">
<tbody>
<tr>
<td valign="top" width="626">
<h2>System.Web.HttpModuleCollection Modules { get; }</h2>
<p> 
<p align="center"><font color="#ffffff"><span style="color:#6682ee;"><font color="#ffffff"><strong></strong>                  <br /></font></span></font></p>
<p align="left"><span style="color:#6682ee;"><font color="#ffffff"><font color="#ffffff"><span style="color:#6682ee;"><font color="#ffffff"><em>Member of System.Web.HttpApplication</em></font></span></font><span style="color:#6682ee;"><font color="#ffffff"> </font></span></font></span></p>
<p align="left"><span style="color:#6682ee;"><font color="#ffffff"><span style="color:#6682ee;"><font color="#ffffff">                   <br />Gets the collection of modules for the current application.</font></span><span style="color:#6682ee;"><font color="#ffffff">Returns:                    <br />An System.Web.HttpModuleCollection that contains the names of the modules for the application.                     <br /></font></span></font></span></p>
</td>
</tr>
</tbody>
</table>
<p><span style="color:#000000;"><a href="http://11011.net/software/vspaste"></a></span></p>
<p>Your first reaction if your familiar with this collection is that it does not have anything even close to the GetIoCModule() method we are calling above.</p>
<p>Indeed this is our &#8216;domain specific&#8217; extension to the .NET Framework API (one of many for this solution).</p>
<p>Here is the implementation of this &#8216;DSL&#8217; extension:</p>
<p><font color="#484848"><span style="background:black 0 50%;color:#808080;">/// &lt;summary&gt;        <br /></span><span style="background:black 0 50%;color:#808080;">/// </span></font><font color="#484848"><span style="background:black 0 50%;color:#008000;">Provides ‘DSL specific’ extensions to the ASP.NET environment for        <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">the IoC Zero Config environment which is not new (after all this becomes a static)</span></font><span style="background:black 0 50%;color:#008000;"><font color="#484848">        <br /></font></span><font color="#484848"><span style="background:black 0 50%;color:#808080;">/// &lt;/summary&gt;        <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">The entire point for extension methods is ‘Fluency in API’ as it allows ‘shorthand’ code</span></font></p>
<p><font color="#484848"><span style="background:black 0 50%;color:#9bdd22;">public static class </span><span style="background:black 0 50%;color:#8bcfe2;">ZeroConfigInstanceResolver </span><span style="background:black 0 50%;color:#feba1b;">{ </span></font></p>
<p><font color="#484848"><span style="background:black 0 50%;color:#9bdd22;">private const string </span><span style="background:black 0 50%;color:#feba1b;">ZeroConfigTypeString = </span><span style="background:black 0 50%;color:#a31515;">&quot;IoCConfigModule.IHttpModel&quot;</span><span style="background:black 0 50%;color:#feba1b;">;</span></font></p>
<p><span style="background:black 0 50%;color:#feba1b;"></span><span style="background:black 0 50%;color:#feba1b;"><font color="#484848">&#160;</font></span><font color="#484848"><span style="background:black 0 50%;color:#808080;">/// &lt;summary&gt;        <br /></span><span style="background:black 0 50%;color:#808080;">/// </span></font><font color="#484848"><span style="background:black 0 50%;color:#008000;">Gets the IZeroConfigDI reference        <br /></span><span style="background:black 0 50%;color:#808080;">/// </span></font><font color="#484848"><span style="background:black 0 50%;color:#008000;">(using domain specific logic and the&#160; <br /></span><span style="background:black 0 50%;color:#808080;">/// </span></font><span style="background:black 0 50%;color:#008000;"><font color="#484848">generic logic extending the container)        <br /></font></span><font color="#484848"><span style="background:black 0 50%;color:#808080;">/// &lt;/summary&gt;        <br /></span><span style="background:black 0 50%;color:#808080;">/// &lt;param name=&quot;container&quot;&gt;</span><span style="background:black 0 50%;color:#008000;">The container.</span></font><font color="#484848"><span style="background:black 0 50%;color:#808080;">&lt;/param&gt;        <br /></span><span style="background:black 0 50%;color:#808080;">/// &lt;returns&gt;&lt;/returns&gt; </span></font></p>
<p><font color="#484848"><span style="background:black 0 50%;color:#9bdd22;">public static </span><span style="background:black 0 50%;color:#2b91af;">IZeroConfigDI </span><span style="background:black 0 50%;color:#feba1b;">GetIoCModule(</span><span style="background:black 0 50%;color:#9bdd22;">this </span><span style="background:black 0 50%;color:#8bcfe2;">HttpModuleCollection </span><span style="background:black 0 50%;color:#feba1b;">container) {</span></font></p>
<p><span style="background:black 0 50%;color:#feba1b;"><font color="#484848">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font></span><span style="background:black 0 50%;color:#9bdd22;"><font color="#484848">return        <br /></font></span><font color="#484848"><span style="background:black 0 50%;color:#feba1b;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; container.FindInstance(        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; () =&gt;         <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; container.Get(ZeroConfigTypeString)         <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="background:black 0 50%;color:#feba1b;">&#160;</span><span style="background:black 0 50%;color:#9bdd22;">as </span><span style="background:black 0 50%;color:#2b91af;">IZeroConfigDI</span><span style="background:black 0 50%;color:#feba1b;">); </span></font></p>
<p><span style="background:black 0 50%;color:#feba1b;"><font color="#484848">}</font></span></p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>As you can see above we are very specific in our intent to add this to the HttpModuleCollection. There is nothing that interesting above except for the method call FindInstance(Func&lt;TResult&gt;) off the target &#8216;container&#8217;. This is a peek into the non-DSL related extension that represents. You might be aware that there is no such FindInstance available off the HttpModuleCollection.</p>
<p>One of our many goals in creating a fluent, easily used API is reducing complexity and providing very maintainable code. Here you can see the Lambada expression required to locate our service is hidden from the developer completely, yet this code is not a &#8216;one-off&#8217; as we have provided both a DSL level extension in concert with a far more generic extension.</p>
<h2>Part 2: Extending the Horizontal to Empower the Domain Specific</h2>
<p>In looking at the HttpModuleCollection, and in our desire to facilitate other sources of resolving our module, it inherits from the abstract parent NameObjectCollectionBase.</p>
<p>Here is the definition of what inherits from this abstract parent:</p>
<table cellspacing="0" cellpadding="2" width="400" border="1">
<tbody>
<tr>
<td valign="top" width="400"> <br />
<h2>public abstract class NameObjectCollectionBase </h2>
<p>Member of System.Collections.SpecializedSummary:           </p>
<p><em>Provides the abstract base class for a collection of associated System.String keys and System.Object values that can be accessed either with the key or with the index.</em></td>
</tr>
</tbody>
</table>
<p><a href="http://dcarr.files.wordpress.com/2008/05/found.jpg"></a></p>
<p>The issue arises as this abstract base leaves it up to its concrete implementer to provide the indexer (or say Get() method) to access the object desired. Therefore a nice way to enhance this abstract type to work across all of the children is to literally pass in the method to resolve the object desired.</p>
<h2>Part 3 : The Generic Extension</h2>
<p>Here is the trivial extension method used to &#8216;open up&#8217; the NameObjectCollectionBase and which is used above:</p>
<p><span style="background:black 0 50%;color:#808080;">/// &lt;summary&gt;      <br />/// </span><span style="background:black 0 50%;color:#008000;">Finds the instance in the NameObjectCollectionBase      <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">using the Functor      <br /></span><span style="background:black 0 50%;color:#808080;">/// &lt;/summary&gt;      <br />/// &lt;typeparam name=&quot;TContainer&quot;&gt;</span><span style="background:black 0 50%;color:#008000;">The type of the container.</span><span style="background:black 0 50%;color:#808080;">&lt;/typeparam&gt;      <br />/// &lt;typeparam name=&quot;TResult&quot;&gt;</span><span style="background:black 0 50%;color:#008000;">The type of the result.</span><span style="background:black 0 50%;color:#808080;">&lt;/typeparam&gt;      <br />/// &lt;param name=&quot;container&quot;&gt;</span><span style="background:black 0 50%;color:#008000;">The container.</span><span style="background:black 0 50%;color:#808080;">&lt;/param&gt;      <br />/// &lt;param name=&quot;finder&quot;&gt;</span><span style="background:black 0 50%;color:#008000;">The finder.</span><span style="background:black 0 50%;color:#808080;">&lt;/param&gt;      <br />/// &lt;returns&gt;&lt;/returns&gt;       <br /></span><span style="background:black 0 50%;color:#9bdd22;">public static </span><span style="background:black 0 50%;color:#feba1b;">TResult FindInstance&lt;TContainer, TResult&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160; (</span><span style="background:black 0 50%;color:#9bdd22;">this </span><span style="background:black 0 50%;color:#feba1b;">TContainer container, </span><span style="background:black 0 50%;color:#2b91af;">Func</span><span style="background:black 0 50%;color:#feba1b;">&lt;TResult&gt; finder)      <br /></span><span style="background:black 0 50%;color:#9bdd22;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; where </span><span style="background:black 0 50%;color:#feba1b;">TContainer : </span><span style="background:black 0 50%;color:#8bcfe2;">NameObjectCollectionBase </span><span style="background:black 0 50%;color:#9bdd22;">where </span><span style="background:black 0 50%;color:#feba1b;">TResult : </span><span style="background:black 0 50%;color:#9bdd22;">class </span><span style="background:black 0 50%;color:#feba1b;">{ </span></p>
<p><span style="background:black 0 50%;color:#feba1b;">     <br /></span><span style="background:black 0 50%;color:#9bdd22;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return </span><span style="background:black 0 50%;color:#feba1b;">finder();      </p>
<p>} </span></p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Since we cannot abstract up the get method, we take a page from Functional Programming and literally pass in the code to execute (which we do above).</p>
<p>A common pattern is to expose methods like the above, but add additional versions that allow more parameters into the Func&lt;TResult&gt;. This is well covered well by many of the Linq references and books available.</p>
<h2>Part 4: How this allows us to embrace deep/wide change</h2>
<p>A simplistic example is supporting the acquisitions of our target reference (IZeroConfigDI) if it is set as ApplicationState or as an IHttpModule. We could make the design decision to allow our find method to reside literally as an extension method of our HttpApplication (and indeed this turns out to be a reasonable choice as the valid inheritors from NameObjectCollectionBase are sealed and therefore invalid as generic constraints). Here is one approach (not ideal and not our final code but this illustrates the point.) Why not offer your optimized solution?</p>
<p>CODE:</p>
<p><span style="background:black 0 50%;color:#9bdd22;">public abstract class </span><span style="background:black 0 50%;color:#8bcfe2;">IntegrationPoint </span><span style="background:black 0 50%;color:#feba1b;">: </span><span style="background:black 0 50%;color:#8bcfe2;">HttpApplication</span><span style="background:black 0 50%;color:#feba1b;">, </span><span style="background:black 0 50%;color:#2b91af;">IDomainApplication </span><span style="background:black 0 50%;color:#feba1b;">{</span> </p>
</p>
<p> <span style="background:black 0 50%;color:#9bdd22;">private static </span><span style="background:black 0 50%;color:#2b91af;">IZeroConfigDI </span><span style="background:black 0 50%;color:#feba1b;">_container;</span>
</p>
<p> <span style="background:black 0 50%;color:#808080;">/// &lt;summary&gt;    <br />/// </span><span style="background:black 0 50%;color:#008000;">Executes custom initialization code after    <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">all event handler    <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">modules have been added.    <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">Also acquire a reference to the HttpModule    <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">or Application State    <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">for IoC / DI if present    <br /></span><span style="background:black 0 50%;color:#808080;">/// &lt;/summary&gt;    <br /></span><span style="background:black 0 50%;color:#9bdd22;">public override void </span><span style="background:black 0 50%;color:#feba1b;">Init() { </span>
</p>
<p><span style="background:black 0 50%;color:#feba1b;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; _container = </span><span style="background:black 0 50%;color:#9bdd22;">this</span><span style="background:black 0 50%;color:#feba1b;">.GetIoCModule(); </span><span style="background:black 0 50%;color:#9bdd22;">base</span><span style="background:black 0 50%;color:#feba1b;">.Init(); </span></p>
<p><span style="background:black 0 50%;color:#feba1b;">}</span></p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>And the extension on HttpApplication:</p>
<p><span style="background:black 0 50%;color:#9bdd22;">public static class </span><span style="background:black 0 50%;color:#8bcfe2;">ZeroConfigInstanceResolver </span><span style="background:black 0 50%;color:#feba1b;">{</span> </p>
</p>
<p> <span style="background:black 0 50%;color:#9bdd22;">private const string </span><span style="background:black 0 50%;color:#feba1b;">ZeroConfigTypeString = </span><span style="background:black 0 50%;color:#a31515;">&quot;IoCConfigModule.IHttpModel&quot;</span><span style="background:black 0 50%;color:#feba1b;">;</span>
</p>
<p> <span style="background:black 0 50%;color:#808080;">/// &lt;summary&gt;    <br />/// </span><span style="background:black 0 50%;color:#008000;">Gets the IZeroConfigDI reference if possible (null if not found)    <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">using domain specific logic and the    <br /></span><span style="background:black 0 50%;color:#808080;">/// </span><span style="background:black 0 50%;color:#008000;">generic logic extending the container.    <br /></span><span style="background:black 0 50%;color:#808080;">/// &lt;/summary&gt;    <br />/// &lt;param name=&quot;container&quot;&gt;</span><span style="background:black 0 50%;color:#008000;">The container.</span><span style="background:black 0 50%;color:#808080;">&lt;/param&gt;    <br />/// &lt;returns&gt;&lt;/returns&gt;     <br /></span><span style="background:black 0 50%;color:#9bdd22;">public static </span><span style="background:black 0 50%;color:#2b91af;">IZeroConfigDI </span><span style="background:black 0 50%;color:#feba1b;">GetIoCModule(</span><span style="background:black 0 50%;color:#9bdd22;">this </span><span style="background:black 0 50%;color:#8bcfe2;">HttpApplication </span><span style="background:black 0 50%;color:#feba1b;">container) {</span>
</p>
<p><span style="background:black 0 50%;color:#9bdd22;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var </span><span style="background:black 0 50%;color:#feba1b;">modules = container.Modules;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="background:black 0 50%;color:#9bdd22;">var </span><span style="background:black 0 50%;color:#feba1b;">applicationState = container.Application;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></p>
<p><span style="background:black 0 50%;color:#feba1b;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="background:black 0 50%;color:#9bdd22;">var </span><span style="background:black 0 50%;color:#feba1b;">resultVar = modules.ToInstance(      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; () =&gt; modules.Get(ZeroConfigTypeString)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; )       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="background:black 0 50%;color:#feba1b;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ??&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; applicationState.ToInstance(       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; () =&gt; </span><span style="background:black 0 50%;color:#feba1b;">applicationState.Get(ZeroConfigTypeString)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; );</span> </p>
</p>
<p> <span style="background:black 0 50%;color:#9bdd22;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return </span><span style="background:black 0 50%;color:#feba1b;">resultVar </span><span style="background:black 0 50%;color:#9bdd22;">as </span><span style="background:black 0 50%;color:#2b91af;">IZeroConfigDI</span><span style="background:black 0 50%;color:#feba1b;">;    </p>
<p>}</span>
</p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>No change is required on the extension to the FindInstance extension.</p>
<p>Can you see how the above can be improved?</p>
<p>We expand this to make the ‘rule for finding the <span style="background:black 0 50%;color:#2b91af;">IZeroConfigDI</span> external. To be specific, above we have a business rule implemented that we typically would not want ‘hard coded’. In fact more then not all things considered we want this. So we do the4 following:</p>
<ul>
<li>Determine the Delegate signature for the business rule.      </li>
<li>For the above, we need as input (at a minimum) an <span style="background:black 0 50%;color:#8bcfe2;">HttpApplication </span>instance as that is the container for the models and state, and those two items lack a shared interface or base (or we could use that).       </li>
<li>The signature returns (in all cases) an instance cast where it implement <span style="background:black 0 50%;color:#2b91af;">IZeroConfigDI </span>to resolve this business rule.       </li>
<li>Therefore the business rule signature is <strong>Func&lt;<span style="background:black 0 50%;color:#8bcfe2;">HttpApplication </span>,<span style="background:black 0 50%;color:#2b91af;">IZeroConfigDI</span>&gt;</strong>       </li>
</ul>
<p><strong></strong></p>
<table cellspacing="0" cellpadding="2" width="355" border="1">
<tbody>
<tr>
<td valign="top" width="353">
<p><strong></strong></p>
<p>         <strong>
<p>&#160;</p>
<p>         </strong>
<ul>
<li>
<h3>It’s an essential skill to not only master generics at the deepest level, but to master all the intrinsic delegate types (Predicate, Func, Action, etc.) to be proficient in the state of the technology of Linq today </h3>
<p></li>
<li>
<h3>We wish it was easier to ‘extend’ Delegates by inheritance or to not be tasked with coding to each variant of a delegates possible type parameters, but this is different the Object Oriented in it’s domain. </h3>
<p></li>
<li>
<h3>We also wish the generic constraint language would be fundamentally focused on, extended and evolved to allow the full richness in constraint semantics as we have with Linq Expressions. </h3>
<p></li>
</ul>
</td>
</tr>
</tbody>
</table>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dcarr.wordpress.com/238/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dcarr.wordpress.com/238/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dcarr.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dcarr.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dcarr.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dcarr.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dcarr.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dcarr.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dcarr.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dcarr.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dcarr.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dcarr.wordpress.com/238/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=team.pushbomb.com&blog=2366446&post=238&subd=dcarr&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://team.pushbomb.com/2008/05/27/advanced-c-30-part-3-new-language-features-as-domain-specific-as-well-as-general-purpose-extensions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7b572cbcda5a17fe984e7dd1ddc9c3d6?s=96&#38;d=&#38;r=PG" medium="image">
			<media:title type="html">pushbomb</media:title>
		</media:content>
	</item>
		<item>
		<title>Advanced C# 3.0 : Part 2 &#8211; Everyday Tasks with New Solutions</title>
		<link>http://team.pushbomb.com/2008/05/22/advanced-c-30-part-2-everyday-tasks-with-new-solutions/</link>
		<comments>http://team.pushbomb.com/2008/05/22/advanced-c-30-part-2-everyday-tasks-with-new-solutions/#comments</comments>
		<pubDate>Thu, 22 May 2008 19:31:10 +0000</pubDate>
		<dc:creator>Damon Wilder Carr</dc:creator>
				<category><![CDATA[C# 3.0 Enhancements]]></category>
		<category><![CDATA[C# 3.0 for Internal DSL]]></category>
		<category><![CDATA[Software Design]]></category>
		<category><![CDATA[Software Futures]]></category>
		<category><![CDATA[agile practices]]></category>
		<category><![CDATA[reflection]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>
		<category><![CDATA[Lambada]]></category>
		<category><![CDATA[Advanced C#]]></category>
		<category><![CDATA[Functional Programming]]></category>
		<category><![CDATA[Delegates]]></category>

		<guid isPermaLink="false">http://dcarr.wordpress.com/2008/05/22/advanced-c-30-part-2-everyday-tasks-with-new-solutions/</guid>
		<description><![CDATA[In this post I'll be digging deeper into doing things I've always wanted to have in .NET yet didn't. For example, I know I am not alone in wanting an IList (be it an IList or a simple non-generic IList) to provide me a .foreach method as you get in a List). This is just one of many things we address here (and more).<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=team.pushbomb.com&blog=2366446&post=232&subd=dcarr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<h3>Part 2 : Digging Deeper into Lambadas, Extension Methods, and Linq</h3>
<p>The world’s most common extension method and an attempt at a definitive version.</p>
<p>In this post I&#8217;ll be digging deeper into doing things I&#8217;ve always wanted to have in .NET yet didn&#8217;t. For example, I know I am not alone in wanting an IList (be it an IList&lt;T&gt; or a simple non-generic IList) to provide me a .foreach method as you get in a List&lt;T&gt;). This is just one of many things we address here (and more).</p>
<h1>From the concrete to the abstract</h1>
<p>I was having problems with entries in my path environmental variable, and I wanted an easy way to flag bad entries and also allow me to move the entries in the list up or down easily. This was made apparent by my use of a tool called &#8216;Dependency Walker&#8217;. It&#8217;s hard to live without but that&#8217;s another post. See the screen shot below:</p>
<p><a href="http://dcarr.files.wordpress.com/2008/05/image-0001.png"><img style="border-width:0;" alt="Image-0001" src="http://dcarr.files.wordpress.com/2008/05/image-0001-thumb.png?w=458&#038;h=316" width="458" height="316" /></a></p>
<p><a href="http://www.dependencywalker.com/">Click here to go to &#8216;Dependency Walker&#8217;</a></p>
<h1>Test to Code</h1>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<pre class="code"><span style="background:#100d0c;color:#e1b04a;"><font size="1">    </font></span><span style="background:#100d0c;color:#a0a0a0;"><font size="1">/// &lt;summary&gt;
    /// </font></span><span style="background:#100d0c;color:#80ff00;"><font size="1">Unit Test to Validate that the logic related to     /// 'show combined extensions using paths' is functioning
    </font></span><span style="background:#100d0c;color:#a0a0a0;"><font size="1">/// &lt;/summary&gt;
    /// </font></span><font size="1"><span style="background:#100d0c;color:#80ff00;">Documentation Created 5/22/2008
    </span><span style="background:#100d0c;color:#e1b04a;">[</span><span style="background:#100d0c;color:#64b1ff;">Test</span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">]
    </span><span style="background:#100d0c;color:#8ac5ff;">public void </span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">shouldShowCombinedExtensionsUsingPaths()
    {
        </span><span style="background:#100d0c;color:#8ac5ff;">var </span><span style="background:#100d0c;color:#e1b04a;">_directoriesInPath </span><span style="background:#100d0c;color:silver;">= </span><span style="background:#100d0c;color:#d6adad;">EnvironmentVariableTarget</span></font><font size="1"><span style="background:#100d0c;color:silver;">.             </span><span style="background:#100d0c;color:#e1b04a;">Process</span><span style="background:#100d0c;color:silver;">.</span><span style="background:#100d0c;color:#e1b04a;">GetParsedValues(</span><span style="background:#100d0c;color:#ff8040;">&quot;PATH&quot;</span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">);

        </span><span style="background:#100d0c;color:#64b1ff;">Assert</span><span style="background:#100d0c;color:silver;">.</span><span style="background:#100d0c;color:#e1b04a;">That(_directoriesInPath, </span><span style="background:#100d0c;color:#64b1ff;">Is</span></font><font size="1"><span style="background:#100d0c;color:silver;">.                </span><span style="background:#100d0c;color:#e1b04a;">TypeOf(</span><span style="background:#100d0c;color:#8ac5ff;">typeof</span><span style="background:#100d0c;color:#e1b04a;">(</span><span style="background:#100d0c;color:#64b1ff;">String</span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">[])));
        </span><span style="background:#100d0c;color:#64b1ff;">Assert</span><span style="background:#100d0c;color:silver;">.</span><span style="background:#100d0c;color:#e1b04a;">IsTrue(</span><span style="background:#100d0c;color:silver;">!</span><span style="background:#100d0c;color:#e1b04a;">_directoriesInPath</span><span style="background:#100d0c;color:silver;">.</span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">IsNullOrEmpty());

        _directoriesInPath</span><span style="background:#100d0c;color:silver;">.</span></font><span style="background:#100d0c;color:#e1b04a;"><font size="1">ForEach(
            x </font></span><span style="background:#100d0c;color:silver;"><font size="1">=&gt;
            </font></span><font size="1"><span style="background:#100d0c;color:#e1b04a;">{
                </span><span style="background:#100d0c;color:#8ac5ff;">if </span><span style="background:#100d0c;color:#e1b04a;">(</span><span style="background:#100d0c;color:silver;">!</span><span style="background:#100d0c;color:#64b1ff;">Directory</span><span style="background:#100d0c;color:silver;">.</span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">Exists(x))
                    </span><span style="background:#100d0c;color:#64b1ff;">Console</span><span style="background:#100d0c;color:silver;">.</span><span style="background:#100d0c;color:#e1b04a;">WriteLine(</span><span style="background:#100d0c;color:#ff8040;">&quot;MIssing Directory! &quot; </span><span style="background:#100d0c;color:silver;">+ </span></font><span style="background:#100d0c;color:#e1b04a;"><font size="1">x);
            });
    }</font></span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Above is the test (that also works). Before I launch into why this is interesting, what looks different?</p>
<p>1) EnvironmentVariableTarget : This is Microsoft&#8217;s type not mine. It&#8217;s the enum used to specify the target search on the environmentals.</p>
<p>2) _directoriesInPath : This is a string[] as you can see from the Assertion. But how does it support ForEach?</p>
<p>3) GetParsedValues() : What is that exactly?</p>
<blockquote>
<p>*** As this is so common I decided to try to craft a definitive version of ForEach that would work across non-generic collections, generic collection, and specific type specification on the targeted items in the collection for generics .&#160; ***</p>
</blockquote>
<p>In order to enable ForEach behavior I needed to this code which is by far the most common extension method in all the C# 3.0 code alive today.</p>
<p>&#160;</p>
<pre class="code">
<span style="background:#100d0c;color:#e1b04a;"><font size="1">    </font></span><span style="background:#100d0c;color:#a0a0a0;"><font size="1">/// &lt;summary&gt;
    /// </font></span><span style="background:#100d0c;color:#80ff00;"><font size="1">Requires generic IEnumerable and is most common now
    </font></span><font size="1"><span style="background:#100d0c;color:#a0a0a0;">/// &lt;/summary&gt;
    /// &lt;typeparam name=</span><span style="background:#100d0c;color:#919191;">&quot;TContainedType&quot;</span><span style="background:#100d0c;color:#a0a0a0;">&gt;</span><span style="background:#100d0c;color:#80ff00;">The type of the contained type.</span></font><font size="1"><span style="background:#100d0c;color:#a0a0a0;">&lt;/typeparam&gt;
    /// &lt;param name=</span><span style="background:#100d0c;color:#919191;">&quot;baseEnum&quot;</span><span style="background:#100d0c;color:#a0a0a0;">&gt;</span><span style="background:#100d0c;color:#80ff00;">The base enum.</span></font><font size="1"><span style="background:#100d0c;color:#a0a0a0;">&lt;/param&gt;
    /// &lt;param name=</span><span style="background:#100d0c;color:#919191;">&quot;actionPerform&quot;</span><span style="background:#100d0c;color:#a0a0a0;">&gt;</span><span style="background:#100d0c;color:#80ff00;">The action perform.</span></font><span style="background:#100d0c;color:#a0a0a0;"><font size="1">&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    /// </font></span><font size="1"><span style="background:#100d0c;color:#80ff00;">Documentation Created 7/20/2008
    </span><span style="background:#100d0c;color:#8ac5ff;">public static </span><span style="background:#100d0c;color:#ff6fb7;">IEnumerable</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#e1b04a;">TContainedType</span><span style="background:#100d0c;color:silver;">&gt; </span><span style="background:#100d0c;color:#e1b04a;">ForEach</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#e1b04a;">TContainedType</span><span style="background:#100d0c;color:silver;">&gt;</span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">(
           </span><span style="background:#100d0c;color:#8ac5ff;">this </span><span style="background:#100d0c;color:#ff6fb7;">IEnumerable</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#e1b04a;">TContainedType</span><span style="background:#100d0c;color:silver;">&gt; </span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">baseEnum,
               </span><span style="background:#100d0c;color:#ffaeff;">Action</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#e1b04a;">TContainedType</span><span style="background:#100d0c;color:silver;">&gt; </span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">actionPerform) {

        </span><span style="background:#100d0c;color:#8ac5ff;">return </span></font><span style="background:#100d0c;color:#e1b04a;"><font size="1">ForEachInner(baseEnum, actionPerform);
    }

    </font></span><span style="background:#100d0c;color:#a0a0a0;"><font size="1">/// &lt;summary&gt;
    /// </font></span><span style="background:#100d0c;color:#80ff00;"><font size="1">The most explicit case
    </font></span><font size="1"><span style="background:#100d0c;color:#a0a0a0;">/// &lt;/summary&gt;
    /// &lt;typeparam name=</span><span style="background:#100d0c;color:#919191;">&quot;TBase&quot;</span><span style="background:#100d0c;color:#a0a0a0;">&gt;</span><span style="background:#100d0c;color:#80ff00;">The type of the base.</span></font><font size="1"><span style="background:#100d0c;color:#a0a0a0;">&lt;/typeparam&gt;
    /// &lt;typeparam name=</span><span style="background:#100d0c;color:#919191;">&quot;TContainedType&quot;</span><span style="background:#100d0c;color:#a0a0a0;">&gt;</span><span style="background:#100d0c;color:#80ff00;">The type of the contained type.</span></font><font size="1"><span style="background:#100d0c;color:#a0a0a0;">&lt;/typeparam&gt;
    /// &lt;param name=</span><span style="background:#100d0c;color:#919191;">&quot;baselineEnumerable&quot;</span><span style="background:#100d0c;color:#a0a0a0;">&gt;</span><span style="background:#100d0c;color:#80ff00;">The baseline enumerable.</span></font><font size="1"><span style="background:#100d0c;color:#a0a0a0;">&lt;/param&gt;
    /// &lt;param name=</span><span style="background:#100d0c;color:#919191;">&quot;actionPerform&quot;</span><span style="background:#100d0c;color:#a0a0a0;">&gt;</span><span style="background:#100d0c;color:#80ff00;">The action perform.</span></font><span style="background:#100d0c;color:#a0a0a0;"><font size="1">&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    /// </font></span><font size="1"><span style="background:#100d0c;color:#80ff00;">Documentation Created 7/20/2008
    </span><span style="background:#100d0c;color:#8ac5ff;">public static </span><span style="background:#100d0c;color:#ff6fb7;">IEnumerable</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#e1b04a;">TContainedType</span><span style="background:#100d0c;color:silver;">&gt; </span><span style="background:#100d0c;color:#e1b04a;">ForEach</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#e1b04a;">TBase, TContainedType</span><span style="background:#100d0c;color:silver;">&gt;</span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">(
              </span><span style="background:#100d0c;color:#8ac5ff;">this </span><span style="background:#100d0c;color:#e1b04a;">TBase baselineEnumerable, </span><span style="background:#100d0c;color:#ffaeff;">Action</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#e1b04a;">TContainedType</span><span style="background:#100d0c;color:silver;">&gt; </span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">actionPerform)
                   </span><span style="background:#100d0c;color:#8ac5ff;">where </span><span style="background:#100d0c;color:#e1b04a;">TBase : </span><span style="background:#100d0c;color:#ff6fb7;">IEnumerable </span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">{

        </span><span style="background:#100d0c;color:#8ac5ff;">return </span><span style="background:#100d0c;color:#e1b04a;">ForEachInner(baselineEnumerable</span><span style="background:#100d0c;color:silver;">.</span><span style="background:#100d0c;color:#e1b04a;">OfType</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#e1b04a;">TContainedType</span><span style="background:#100d0c;color:silver;">&gt;</span></font><span style="background:#100d0c;color:#e1b04a;"><font size="1">(), actionPerform);
    }

    </font></span><span style="background:#100d0c;color:#a0a0a0;"><font size="1">/// &lt;summary&gt;
    /// </font></span><span style="background:#100d0c;color:#80ff00;"><font size="1">The least restrictive case
    </font></span><font size="1"><span style="background:#100d0c;color:#a0a0a0;">/// &lt;/summary&gt;
    /// &lt;param name=</span><span style="background:#100d0c;color:#919191;">&quot;baseEnum&quot;</span><span style="background:#100d0c;color:#a0a0a0;">&gt;</span><span style="background:#100d0c;color:#80ff00;">The base enum.</span></font><font size="1"><span style="background:#100d0c;color:#a0a0a0;">&lt;/param&gt;
    /// &lt;param name=</span><span style="background:#100d0c;color:#919191;">&quot;actionPerform&quot;</span><span style="background:#100d0c;color:#a0a0a0;">&gt;</span><span style="background:#100d0c;color:#80ff00;">The action perform.</span></font><span style="background:#100d0c;color:#a0a0a0;"><font size="1">&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    /// </font></span><font size="1"><span style="background:#100d0c;color:#80ff00;">Documentation Created 7/20/2008
    </span><span style="background:#100d0c;color:#8ac5ff;">public static </span><span style="background:#100d0c;color:#ff6fb7;">IEnumerable</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#64b1ff;">Object</span><span style="background:#100d0c;color:silver;">&gt; </span><span style="background:#100d0c;color:#e1b04a;">ForEach(</span><span style="background:#100d0c;color:#8ac5ff;">this </span><span style="background:#100d0c;color:#ff6fb7;">IEnumerable </span><span style="background:#100d0c;color:#e1b04a;">baseEnum,                </span><span style="background:#100d0c;color:#ffaeff;">Action</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#64b1ff;">Object</span></font><span style="background:#100d0c;color:silver;"><font size="1">&gt;  </font></span><font size="1"><span style="background:#100d0c;color:#e1b04a;">actionPerform) {

        </span><span style="background:#100d0c;color:#8ac5ff;">return </span><span style="background:#100d0c;color:#e1b04a;">ForEachInner(baseEnum</span><span style="background:#100d0c;color:silver;">.</span><span style="background:#100d0c;color:#e1b04a;">OfType</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#64b1ff;">Object</span><span style="background:#100d0c;color:silver;">&gt;</span></font><span style="background:#100d0c;color:#e1b04a;"><font size="1">(), actionPerform);
    }

    </font></span><span style="background:#100d0c;color:#a0a0a0;"><font size="1">/// &lt;summary&gt;
    /// </font></span><span style="background:#100d0c;color:#80ff00;"><font size="1">Do the actual work
    </font></span><font size="1"><span style="background:#100d0c;color:#a0a0a0;">/// &lt;/summary&gt;
    /// &lt;typeparam name=</span><span style="background:#100d0c;color:#919191;">&quot;TContainedType&quot;</span><span style="background:#100d0c;color:#a0a0a0;">&gt;</span><span style="background:#100d0c;color:#80ff00;">The type of the contained type.</span></font><font size="1"><span style="background:#100d0c;color:#a0a0a0;">&lt;/typeparam&gt;
    /// &lt;param name=</span><span style="background:#100d0c;color:#919191;">&quot;baseEnum&quot;</span><span style="background:#100d0c;color:#a0a0a0;">&gt;</span><span style="background:#100d0c;color:#80ff00;">The base enum.</span></font><font size="1"><span style="background:#100d0c;color:#a0a0a0;">&lt;/param&gt;
    /// &lt;param name=</span><span style="background:#100d0c;color:#919191;">&quot;actionPerform&quot;</span><span style="background:#100d0c;color:#a0a0a0;">&gt;</span><span style="background:#100d0c;color:#80ff00;">The action perform.</span></font><span style="background:#100d0c;color:#a0a0a0;"><font size="1">&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    /// </font></span><font size="1"><span style="background:#100d0c;color:#80ff00;">Documentation Created 7/20/2008
    </span><span style="background:#100d0c;color:#8ac5ff;">private static </span><span style="background:#100d0c;color:#ff6fb7;">IEnumerable</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#e1b04a;">TContainedType</span><span style="background:#100d0c;color:silver;">&gt; </span><span style="background:#100d0c;color:#e1b04a;">ForEachInner</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#e1b04a;">TContainedType</span><span style="background:#100d0c;color:silver;">&gt;</span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">(
        </span><span style="background:#100d0c;color:#ff6fb7;">IEnumerable</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#e1b04a;">TContainedType</span><span style="background:#100d0c;color:silver;">&gt; </span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">baseEnum,
                       </span><span style="background:#100d0c;color:#ffaeff;">Action</span><span style="background:#100d0c;color:silver;">&lt;</span><span style="background:#100d0c;color:#e1b04a;">TContainedType</span><span style="background:#100d0c;color:silver;">&gt; </span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">actionPerform) {

        </span><span style="background:#100d0c;color:#8ac5ff;">var </span><span style="background:#100d0c;color:#e1b04a;">getEnumerate </span><span style="background:#100d0c;color:silver;">= </span><span style="background:#100d0c;color:#e1b04a;">baseEnum</span><span style="background:#100d0c;color:silver;">.</span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">ToList();
        getEnumerate</span><span style="background:#100d0c;color:silver;">.</span></font><font size="1"><span style="background:#100d0c;color:#e1b04a;">ForEach(actionPerform);

        </span><span style="background:#100d0c;color:#8ac5ff;">return </span></font><span style="background:#100d0c;color:#e1b04a;"><font size="1">getEnumerate;
    }</font></span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>Notice that anything which implements IEnumerable is caught above, regardless of what the collection.</p>
<p>&#160;</p>
<div style="float:none;display:inline;margin:0;padding:0;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:eb68bac9-98d9-4f88-a664-8c985a219755" class="wlWriterSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/Advanced+C%23" rel="tag">Advanced C#</a>,<a href="http://del.icio.us/popular/C%23" rel="tag">C#</a>,<a href="http://del.icio.us/popular/C%23+3.0+for+Internal+DSL" rel="tag">C# 3.0 for Internal DSL</a>,<a href="http://del.icio.us/popular/Delegates" rel="tag">Delegates</a>,<a href="http://del.icio.us/popular/Functional+Programming" rel="tag">Functional Programming</a>,<a href="http://del.icio.us/popular/Lambada" rel="tag">Lambada</a>,<a href="http://del.icio.us/popular/linq" rel="tag">linq</a>,<a href="http://del.icio.us/popular/Visual+Studio+2008" rel="tag">Visual Studio 2008</a></div>
</p>
</p>
</p>
<p><div style="float:none;display:inline;margin:0;padding:0;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:1e50a19d-51fa-4053-b31f-4ed321648963" class="wlWriterSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Advanced+C%23" rel="tag">Advanced C#</a>,<a href="http://technorati.com/tags/C%23" rel="tag">C#</a>,<a href="http://technorati.com/tags/C%23+3.0+for+Internal+DSL" rel="tag">C# 3.0 for Internal DSL</a>,<a href="http://technorati.com/tags/Delegates" rel="tag">Delegates</a>,<a href="http://technorati.com/tags/Functional+Programming" rel="tag">Functional Programming</a>,<a href="http://technorati.com/tags/Lambada" rel="tag">Lambada</a>,<a href="http://technorati.com/tags/linq" rel="tag">linq</a>,<a href="http://technorati.com/tags/Visual+Studio+2008" rel="tag">Visual Studio 2008</a></div>
</p>
<div class="wlWriterHeaderFooter" style="text-align:right;margin:0;padding:4px 0;"><a href="http://digg.com/submit?url=http%3a%2f%2fdcarr.wordpress.com%2f2008%2f05%2f22%2fadvanced-c-30-part-2-everyday-tasks-with-new-solutions%2f&amp;title=Advanced+C%23+3.0+%3a+Part+2+-+Everyday+Tasks+with+New+Solutions"><img src="http://digg.com/img/badges/100x20-digg-button.png" width="100" height="20" alt="Digg This" border="0" style="border:0;" /></a></div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dcarr.wordpress.com/232/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dcarr.wordpress.com/232/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dcarr.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dcarr.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dcarr.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dcarr.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dcarr.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dcarr.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dcarr.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dcarr.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dcarr.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dcarr.wordpress.com/232/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=team.pushbomb.com&blog=2366446&post=232&subd=dcarr&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://team.pushbomb.com/2008/05/22/advanced-c-30-part-2-everyday-tasks-with-new-solutions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7b572cbcda5a17fe984e7dd1ddc9c3d6?s=96&#38;d=&#38;r=PG" medium="image">
			<media:title type="html">pushbomb</media:title>
		</media:content>

		<media:content url="http://dcarr.files.wordpress.com/2008/05/image-0001-thumb.png" medium="image">
			<media:title type="html">Image-0001</media:title>
		</media:content>

		<media:content url="http://digg.com/img/badges/100x20-digg-button.png" medium="image">
			<media:title type="html">Digg This</media:title>
		</media:content>
	</item>
		<item>
		<title>ReSharper 4 &#8212; Latest Status Update from Ilya Ryzhenkov</title>
		<link>http://team.pushbomb.com/2008/05/14/resharper-4-latest-status-update-from-ilya-ryzhenkov/</link>
		<comments>http://team.pushbomb.com/2008/05/14/resharper-4-latest-status-update-from-ilya-ryzhenkov/#comments</comments>
		<pubDate>Wed, 14 May 2008 07:34:14 +0000</pubDate>
		<dc:creator>Damon Wilder Carr</dc:creator>
				<category><![CDATA[Software Design]]></category>
		<category><![CDATA[Software Futures]]></category>
		<category><![CDATA[reflection]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[Resharper]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[JetBrains]]></category>

		<guid isPermaLink="false">http://dcarr.wordpress.com/2008/05/14/resharper-4-latest-status-update-from-ilya-ryzhenkov/</guid>
		<description><![CDATA[Well, overall time scope for ReSharper 4 release is about a month. Thank you for your patience, we really appreciate your participation in our early access program! We are doing our best to deliver smart and quality product. And while we are here, what is *single* most important thing you want to be fixed/changed before release?<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=team.pushbomb.com&blog=2366446&post=187&subd=dcarr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Hello, I must admit, we were not very responsive in the forums for the last month or so. We were<a href="http://dcarr.files.wordpress.com/2008/05/200805140336160109.jpg"><img class="alignright alignnone size-medium wp-image-186" style="float:right;" src="http://dcarr.files.wordpress.com/2008/05/200805140336160109.jpg?w=379&#038;h=284" alt="Home Page" width="379" height="284" /></a></p>
<p>busy developing ReSharper 4 :) Here is quick update. We are currently working on preparing ReSharper for Beta &#8211; performance, memory, overall stability and reliability. Beta should be out very soon. Then we will have</p>
<p>post-Beta cleanup, more stabilization for Release, fill in missing bricks found during Beta, and then &#8230; Well, overall time scope for ReSharper 4 release is about a month. Thank you for your patience, we really appreciate your participation in our early access program! We are doing our best to deliver smart and quality product. And while we are here, what is *single* most important thing you want to be fixed/changed before release?</p>
<blockquote><p>Sincerely,</p>
<p>Ilya Ryzhenkov</p>
<p>JetBrains, Inc</p>
<p>http://www.jetbrains.com &#8220;Develop with pleasure!&#8221;</p></blockquote>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dcarr.wordpress.com/187/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dcarr.wordpress.com/187/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dcarr.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dcarr.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dcarr.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dcarr.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dcarr.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dcarr.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dcarr.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dcarr.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dcarr.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dcarr.wordpress.com/187/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=team.pushbomb.com&blog=2366446&post=187&subd=dcarr&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://team.pushbomb.com/2008/05/14/resharper-4-latest-status-update-from-ilya-ryzhenkov/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7b572cbcda5a17fe984e7dd1ddc9c3d6?s=96&#38;d=&#38;r=PG" medium="image">
			<media:title type="html">pushbomb</media:title>
		</media:content>

		<media:content url="http://dcarr.files.wordpress.com/2008/05/200805140336160109.jpg?w=300" medium="image">
			<media:title type="html">Home Page</media:title>
		</media:content>
	</item>
		<item>
		<title>Daniel Cazzulino&#8217;s Blog : Statically-typed reflection with LINQ</title>
		<link>http://team.pushbomb.com/2008/05/08/daniel-cazzulinos-blog-statically-typed-reflection-with-linq/</link>
		<comments>http://team.pushbomb.com/2008/05/08/daniel-cazzulinos-blog-statically-typed-reflection-with-linq/#comments</comments>
		<pubDate>Thu, 08 May 2008 06:11:24 +0000</pubDate>
		<dc:creator>Damon Wilder Carr</dc:creator>
				<category><![CDATA[C# 3.0 Enhancements]]></category>
		<category><![CDATA[Software Design]]></category>
		<category><![CDATA[Software Futures]]></category>
		<category><![CDATA[reflection]]></category>
		<category><![CDATA[C# 3.0 for Internal DSL]]></category>
		<category><![CDATA[Advanced .NET]]></category>

		<guid isPermaLink="false">http://dcarr.wordpress.com/2008/05/08/daniel-cazzulinos-blog-statically-typed-reflection-with-linq/</guid>
		<description><![CDATA[With .NET 3.5 and C# 3.0 released now, it was time for an update. As part of the update, I also improved the API a little bit. Usage now is:
MethodInfo toString = Reflect.GetMethod(x =&#62; x.ToString());The renamed Reflect class receives the type you want to reflect as a generic parameter. Then you can use GetMethod, GetField or GetProperty.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=team.pushbomb.com&blog=2366446&post=183&subd=dcarr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>To quote Daniel&#8230; : &#8220;Quite some time ago I posted about <a href="http://www.clariusconsulting.net/blogs/kzu/archive/2006/07/06/TypedReflection.aspx">how to use LINQ to provide a strong-typed reflection API</a>. I used a very old LINQ preview back then.</p>
<p>With <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=333325fd-ae52-4e35-b531-508d977d32a6&amp;displaylang=en">.NET 3.5 and C# 3.0 released</a> now, it was time for an update. As part of the update, I also improved the API a little bit. Usage now is:</p>
<pre style="text-align:center;"><strong>MethodInfo toString = Reflect&lt;object&gt;.GetMethod(x =&gt; x.ToString());</strong></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>The renamed <code>Reflect&lt;TTarget&gt;</code> class receives the type you want to reflect as a generic parameter. Then you can use <code>GetMethod</code>, <code>GetField</code> or <code>GetProperty</code>.</p>
<p>Other examples:</p>
<pre style="text-align:center;">MethodInfo clone = Reflect&lt;ICloneable&gt;.GetMethod(x =&gt; x.Clone());
PropertyInfo prop = Reflect&lt;AppDomain&gt;.GetProperty(x =&gt; x.BaseDirectory);
FieldInfo field = Reflect&lt;Mock&gt;.GetField(x =&gt; x.PublicField);</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Working principle is the same: the lambda you pass to the methods is actually an expression</p>
<p>which I analyze to retrieve the underlying reflection object that is already exposed by the LINQ Expression API. For example, once you get to a <a href="http://msdn2.microsoft.com/en-us/library/system.linq.expressions.methodcallexpression.aspx">MethodCallExpression</a>, you can get the method being called through its <a href="http://msdn2.microsoft.com/en-us/library/bb340973.aspx">Method</a> property:</p>
<pre style="text-align:center;">((MethodCallExpression)lambda.Body).Method;</pre>
<p>It&#8217;s interesting to see how this works actually, and what&#8217;s the compiler generating for those lambda expressions invoking methods.</p>
<p>In Reflector, the following C# code:</p>
<p>MethodInfo clone = Reflect&lt;ICloneable&gt;.GetMethod(x =&gt; x.Clone());</p>
<p>is decompiled as (indented for readability):</p>
<pre style="text-align:center;">ParameterExpression CS$0$0000;
MethodInfo clone = Reflect&lt;ICloneable&gt;.GetMethod(
Expression.Lambda&lt;Action&lt;ICloneable&gt;&gt;(Expression.Call(CS$0$0000 =
Expression.Parameter(typeof(ICloneable), "x"),
 (MethodInfo) methodof(ICloneable.Clone), new Expression[0] ),
new ParameterExpression[] { CS$0$0000 }  ));</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Note how the MethodInfo is retrieved directly from the interface by using a <code>methodof</code> operator. It&#8217;s not a valid C# keyword, but given that <a href="http://www.aisto.com/roeder/">Lutz Roeder</a> works for Microsoft (not on the C# team, though), let&#8217;s hope it will get eventually in the language :).</p>
<p>That <code>methodof</code> translation is actually the conversion from the following two IL lines:</p>
<pre style="text-align:center;">L_0017: ldtoken instance object [mscorlib]System.ICloneable::Clone()L_001c: call class
 [mscorlib]System.Reflection.MethodBase</pre>
<pre style="text-align:center;">[mscorlib]System.Reflection.MethodBase::GetMethodFromHandle(valuetype</pre>
<pre style="text-align:center;">[mscorlib]System.RuntimeMethodHandle)</pre>
<p><code>ldtoken</code> is the key there, let&#8217;s hope it gets promoted to C# in some way eventually.</p>
<p>Anyway, since I wrote my original article, I realized through <a href="http://www.ayende.com/Blog/Default.aspx">Ayende&#8217;s blog</a> that you can also do <a href="http://www.ayende.com/Blog/archive/2005/10/29/8176.aspx">static reflection without LINQ</a>. It only works for methods though, and you cannot use the lambda syntax because it results in method infos that are actually from a compiler-generated type (the one that contains the closures too if any).</p>
<p>As I&#8217;m so in love with the lambda syntax, I&#8217;ll keep my implementation based on expression trees instead of delegates.</p>
<p>It&#8217;s released now as part of <a href="http://www.codeplex.com/clarius">Clarius Labs</a> projects. <a href="https://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=clarius&amp;ReleaseId=9495">Get the source</a> and have fun!&#8221;</p>
<p><a href="http://www.clariusconsulting.net/blogs/kzu/archive/2007/12/30/49063.aspx">Daniel Cazzulino&#8217;s Blog : Statically-typed reflection with LINQ</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dcarr.wordpress.com/183/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dcarr.wordpress.com/183/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dcarr.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dcarr.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dcarr.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dcarr.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dcarr.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dcarr.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dcarr.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dcarr.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dcarr.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dcarr.wordpress.com/183/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=team.pushbomb.com&blog=2366446&post=183&subd=dcarr&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://team.pushbomb.com/2008/05/08/daniel-cazzulinos-blog-statically-typed-reflection-with-linq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7b572cbcda5a17fe984e7dd1ddc9c3d6?s=96&#38;d=&#38;r=PG" medium="image">
			<media:title type="html">pushbomb</media:title>
		</media:content>
	</item>
	</channel>
</rss>