<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Living in the Tech Avalanche Generation</title>
	
	<link>http://www.simonsegal.net/blog</link>
	<description>A practitioners introspective on technology</description>
	<pubDate>Wed, 15 Jul 2009 10:13:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/simonsegal/rQlV" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Doing .NET Days – Latest</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/IG9sVpCI7RE/</link>
		<comments>http://www.simonsegal.net/blog/2009/07/15/doing-net-days-latest/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 10:13:01 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/07/15/doing-net-days-latest/</guid>
		<description><![CDATA[The inaugural “doing .NET days” is filling up fast but there are a few spots left. If you are interested in learning more about LINQ and it’s different flavours and getting an introductory look at nServiceBus (a mighty powerful Framework for Distributed Systems development), then please grab one of the few remaining spots before they [...]]]></description>
			<content:encoded><![CDATA[<p>The inaugural “doing .NET days” is filling up fast but there are a few spots left. If you are interested in learning more about LINQ and it’s different flavours and getting an introductory look at <a href="http://www.nservicebus.com/" target="_blank">nServiceBus</a> (a mighty powerful Framework for Distributed Systems development), then please grab one of the few remaining spots before they disappear.</p>
<p>You can find more details about the event <a href="http://www.simonsegal.net/blog/2009/07/08/announcing-doing-net-days-day-1-net-training/" target="_blank">here</a> and <a href="http://www.simonsegal.net/blog/training/" target="_blank">here</a>.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Doing%20.NET%20Days%20%26ndash%3B%20Latest&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F07%2F15%2Fdoing-net-days-latest%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Doing .NET Days &ndash; Latest";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/07/15/doing-net-days-latest/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=IG9sVpCI7RE:LHzDRUSb3kg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=IG9sVpCI7RE:LHzDRUSb3kg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=IG9sVpCI7RE:LHzDRUSb3kg:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=IG9sVpCI7RE:LHzDRUSb3kg:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=IG9sVpCI7RE:LHzDRUSb3kg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=IG9sVpCI7RE:LHzDRUSb3kg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=IG9sVpCI7RE:LHzDRUSb3kg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=IG9sVpCI7RE:LHzDRUSb3kg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=IG9sVpCI7RE:LHzDRUSb3kg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=IG9sVpCI7RE:LHzDRUSb3kg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=IG9sVpCI7RE:LHzDRUSb3kg:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/IG9sVpCI7RE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/07/15/doing-net-days-latest/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/07/15/doing-net-days-latest/</feedburner:origLink></item>
		<item>
		<title>An interesting DDD / TDD Odyssey (oddity?)</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/jtDedIGpx_w/</link>
		<comments>http://www.simonsegal.net/blog/2009/07/14/an-interesting-ddd-tdd-odyssey-oddity/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 12:54:54 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[DDD]]></category>

		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/07/14/an-interesting-ddd-tdd-odyssey-oddity/</guid>
		<description><![CDATA[An interesting circumstance cropped up recently during some practical sessions with work colleagues. Let me set the scene first. I was instructing on TDD and DDD in  the context of an internal company project, there are four developers (including myself), which meant pair programming had now become quad programming. The thing that was interesting (to [...]]]></description>
			<content:encoded><![CDATA[<p>An interesting circumstance cropped up recently during some practical sessions with <a href="http://www.simonsegal.net/blog/wp-content/uploads/2009/07/upsidedownman.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 5px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="upside-down-man" src="http://www.simonsegal.net/blog/wp-content/uploads/2009/07/upsidedownman-thumb.png" border="0" alt="upside-down-man" width="154" height="325" align="left" /></a>work colleagues. Let me set the scene first. I was instructing on TDD and DDD in  the context of an internal company project, there are four developers (including myself), which meant pair programming had now become <strong><em>quad</em></strong> programming. The thing that was interesting (to me) about this project (with respect to DDD), was that we were effectively modelling a business domain where the domain was itself was a database! Strange indeed. Let me explain further.</p>
<p>In this particular industry, there exists a well know database schema that is used commonly to shuttle data to and from a DMS and this often requires a full ETL workflow. The application we are currently working on is targeting a “Transformation” process and hence our model is to a large degree dependent on this ‘little’ schema, which by the way finds it’s way into the physical world as an Access Database(s). Therefore some of the entities in our model were modelled against this database and when you think about DDD this sounds a bit strange since one of the common tasks in that process is to model entities to business concepts and then map those entities to a database. It became even more interesting when we interviewed the business stakeholders and asked them questions about what language and common expressions they use when they describe this database, it’s tables and rows and what they do with it all.</p>
<p>It quickly became apparent that the ubiquitous language in this case was to a large degree describing a database. Strange. At least I thought so.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=An%20interesting%20DDD%20%2F%20TDD%20Odyssey%20%28oddity%3F%29&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F07%2F14%2Fan-interesting-ddd-tdd-odyssey-oddity%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="An interesting DDD / TDD Odyssey (oddity?)";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/07/14/an-interesting-ddd-tdd-odyssey-oddity/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=jtDedIGpx_w:c85e-kMV2Bg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=jtDedIGpx_w:c85e-kMV2Bg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=jtDedIGpx_w:c85e-kMV2Bg:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=jtDedIGpx_w:c85e-kMV2Bg:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=jtDedIGpx_w:c85e-kMV2Bg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=jtDedIGpx_w:c85e-kMV2Bg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=jtDedIGpx_w:c85e-kMV2Bg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=jtDedIGpx_w:c85e-kMV2Bg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=jtDedIGpx_w:c85e-kMV2Bg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=jtDedIGpx_w:c85e-kMV2Bg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=jtDedIGpx_w:c85e-kMV2Bg:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/jtDedIGpx_w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/07/14/an-interesting-ddd-tdd-odyssey-oddity/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/07/14/an-interesting-ddd-tdd-odyssey-oddity/</feedburner:origLink></item>
		<item>
		<title>Announcing “Doing .NET Days” – Day 1 (.NET Training)</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/hxYZ_58h5Q4/</link>
		<comments>http://www.simonsegal.net/blog/2009/07/08/announcing-doing-net-days-day-1-net-training/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 13:09:15 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[LINQ]]></category>

		<category><![CDATA[NServiceBus]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/07/08/announcing-doing-net-days-day-1-net-training/</guid>
		<description><![CDATA[Something that has been on my mind for some time now has been an urge to do some local community  work through my council community centre and “Doing .NET Days” is the expression of that urge. What is “Doing .NET Days”? The idea is that once a month I will be offering free (gold coin [...]]]></description>
			<content:encoded><![CDATA[<p>Something that has been on my mind for some time now has been an urge to do <a href="http://www.simonsegal.net/blog/wp-content/uploads/2009/07/nsb-linq-cool.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="nsb_linq_cool" src="http://www.simonsegal.net/blog/wp-content/uploads/2009/07/nsb-linq-cool-thumb.png" border="0" alt="nsb_linq_cool" width="188" height="244" align="left" /></a>some local community  work through my council community centre and “Doing .NET Days” is the expression of that urge. What is “Doing .NET Days”? The idea is that once a month I will be offering free (gold coin donation) whirlwind introductory level training on a variety of subjects, approximately three subjects per .NET Day!</p>
<p>The venue for “Doing .NET Days” will be static for the time being and the event be conducted at the Point Cook Community Centre in Point Cook Melbourne Australia. The number of seats for the event is limited (size of the room) and for the moment it caters to 10 seats (each with a PC supplied) so if you want to be involved you will need to be in the first 10 to register. if you want to be introduced to something new that you might not have had the time to check out till now.</p>
<h3><span style="text-decoration: underline;">Doing .NET Days – Day #1 Agenda</span></h3>
<p>To kick things off were going to take a look at the following:</p>
<ul>
<li>An introductory look at messaging with NServiceBus.</li>
<li>An introductory look at LINQ and it’s flavour of providers (LINQ To Objects, XML, SQL and Entity Framework)</li>
</ul>
<p>To start off with I am holding 5 seats for graduates yet to find their first developer role in the workforce. I remember what it’s like trying to break in and get that first gig and I would have appreciated the help back then! If the graduate positions are not taken up within the next two weeks, I will open those seats up as well. Here are the rest of the event details:</p>
<ul>
<li>Saturday 22th August 2009</li>
<li>Location – Point Community Centre</li>
<li>10:00 AM – 4:00PM</li>
<li>Lunch is BYO or there are a number of cafes and restaurants in the town centre.</li>
<li>To register <a href="mailto:simon.segal@iinet.net.au" target="_blank">email me</a> your details and I will contact you with further details.</li>
</ul>
<p>I will post a comment on this post every time a position is taken up so people can tell how many positions remain open.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Announcing%20%26ldquo%3BDoing%20.NET%20Days%26rdquo%3B%20%26ndash%3B%20Day%201%20%28.NET%20Training%29&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F07%2F08%2Fannouncing-doing-net-days-day-1-net-training%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Announcing &ldquo;Doing .NET Days&rdquo; &ndash; Day 1 (.NET Training)";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/07/08/announcing-doing-net-days-day-1-net-training/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=hxYZ_58h5Q4:SmO5vsylnvQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=hxYZ_58h5Q4:SmO5vsylnvQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=hxYZ_58h5Q4:SmO5vsylnvQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=hxYZ_58h5Q4:SmO5vsylnvQ:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=hxYZ_58h5Q4:SmO5vsylnvQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=hxYZ_58h5Q4:SmO5vsylnvQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=hxYZ_58h5Q4:SmO5vsylnvQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=hxYZ_58h5Q4:SmO5vsylnvQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=hxYZ_58h5Q4:SmO5vsylnvQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=hxYZ_58h5Q4:SmO5vsylnvQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=hxYZ_58h5Q4:SmO5vsylnvQ:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/hxYZ_58h5Q4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/07/08/announcing-doing-net-days-day-1-net-training/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/07/08/announcing-doing-net-days-day-1-net-training/</feedburner:origLink></item>
		<item>
		<title>Configuring, Testing and Probing NServiceBus with IronPython</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/nqVtl6kn7aQ/</link>
		<comments>http://www.simonsegal.net/blog/2009/07/06/configuring-testing-and-probing-nservicebus-with-ironpython/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 21:44:55 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[IronPython]]></category>

		<category><![CDATA[NServiceBus]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/07/06/configuring-testing-and-probing-nservicebus-with-ironpython/</guid>
		<description><![CDATA[I have recently been working with NServiceBus quite a bit and whilst I was working on a WPF IronPython Console - User Control / Window, it occurred to me that it would be a useful tool in testing and monitoring behaviour of my services whilst running under NServiceBus. Let’s have a look at the simplest [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been working with NServiceBus quite a bit and whilst I was working on a <a href="http://www.simonsegal.net/blog/2009/07/01/an-ironpython-repl-console-in-a-wpf-user-control/" target="_blank">WPF IronPython Console - User Control / Window</a>, it occurred to me that it would be a useful tool in testing and monitoring behaviour of my services whilst running under <a href="http://www.nservicebus.com/" target="_blank">NServiceBus</a>. Let’s have a look at the simplest of examples by configuring up an <a href="http://www.nservicebus.com/Documentation.aspx" target="_blank">IBus</a> and publishing messages using <a href="http://www.udidahan.com/" target="_blank">Udi’s</a> PubSub sample.</p>
<p>The first change to Udi’s sample code comes in the publisher where the <strong><em>main</em></strong> method&#8217;s body no longer contains any configuration code whatsoever.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">using</span> System;
<span style="color: #0000ff;">using</span> Common.Logging;
<span style="color: #0000ff;">using</span> NServiceBus;
<span style="color: #0000ff;">using</span> Messages;
<span style="color: #0000ff;">using</span> System.Collections.Generic;
<span style="color: #0000ff;">using</span> System.ComponentModel;
<span style="color: #0000ff;">using</span> Org.TechA.Wpf.Controls;
<span style="color: #0000ff;">using</span> NServiceBus.Unicast.Transport.Msmq.Config;
<span style="color: #0000ff;">using</span> NServiceBus.Unicast.Transport.Msmq;
<span style="color: #0000ff;">using</span> NServiceBus.ObjectBuilder;

<span style="color: #008000;">//register the extensions for configuration</span>
<span style="color: #008000;">//so IronPython can see the extension methods</span>

[assembly: Microsoft.Scripting.Runtime.ExtensionType(
    <span style="color: #0000ff;">typeof</span>(Configure),
    <span style="color: #0000ff;">typeof</span>(ConfigureSpringBuilder))]

[assembly: Microsoft.Scripting.Runtime.ExtensionType(
    <span style="color: #0000ff;">typeof</span>(Configure),
    <span style="color: #0000ff;">typeof</span>(ConfigureMsmqSubscriptionStorage))]

[assembly: Microsoft.Scripting.Runtime.ExtensionType(
    <span style="color: #0000ff;">typeof</span>(Configure),
    <span style="color: #0000ff;">typeof</span>(ConfigureXmlSerializer))]

[assembly: Microsoft.Scripting.Runtime.ExtensionType(
    <span style="color: #0000ff;">typeof</span>(Configure),
    <span style="color: #0000ff;">typeof</span>(ConfigureMsmqTransport))]

[assembly: Microsoft.Scripting.Runtime.ExtensionType(
    <span style="color: #0000ff;">typeof</span>(Configure),
    <span style="color: #0000ff;">typeof</span>(ConfigureUnicastBus))]

[assembly: Microsoft.Scripting.Runtime.ExtensionType(
    <span style="color: #0000ff;">typeof</span>(Configure),
    <span style="color: #0000ff;">typeof</span>(ConfigureUnicastBus))]

<span style="color: #0000ff;">namespace</span> Server
{
    <span style="color: #0000ff;">class</span> Program
    {
        <span style="color: #0000ff;">static</span> IBus bus = <span style="color: #0000ff;">null</span>;

        [STAThread]
        <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> Main()
        {
            LogManager.GetLogger(<span style="color: #006080;">&#8220;hello&#8221;</span>).Debug(<span style="color: #006080;">&#8220;Started.&#8221;</span>);
            var ir_window = <span style="color: #0000ff;">new</span> ConsoleWindow();
            ir_window.ShowDialog();
        }
    }
}</pre>
</div>
<p>What’s been added here is the decoration of the assembly with a set of ExtensionType attributes from the DLR to allow us to program against the NServiceBus fluent interfaces extension methods from IronPython. The other thing to note in the code above is that the configuration code from the <a href="http://www.nservicebus.com/Examples.aspx" target="_blank">PubSub sample</a> is removed and what now remains is to create and run an instance of the <a href="http://www.simonsegal.net/blog/2009/07/01/an-ironpython-repl-console-in-a-wpf-user-control/" target="_blank">IronPython Application Shell</a>, effectively embedding IronPython into my NServiceBus publisher. Once this is done we are all set to start scripting our services and NServiceBus. If I run this code above I expect to see the the IronPython Application Scripting Window pop up ready for action.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2009/07/iron-bus-publisher.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="click to open in another window" src="http://www.simonsegal.net/blog/wp-content/uploads/2009/07/iron-bus-publisher-thumb.png" border="0" alt="click to open in another window" width="404" height="525" /></a></p>
<h3><span style="text-decoration: underline;">Configure the Bus and Send a message</span></h3>
<p>Here’s a look at a sample script typed at the console window (see above) to configure the bus and start sending some messages.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000;">#import the relevant libraries</span>
from System import *
from NServiceBus import *
import clr

<span style="color: #008000;">#add a reference to the messages</span>
<span style="color: #008000;">#library from the pubsub sample</span>
<span style="color: #008000;">#and import it</span>
clr.AddReference(<span style="color: #006080;">&#8220;Messages&#8221;</span>)
from Messages import *

<span style="color: #008000;">#configure the IBus </span>
<span style="color: #008000;">#NOTE: type this line as a WHOLE in the </span>
<span style="color: #008000;">#IronPython Console Window</span>
bus = Configure.With()
                .SpringBuilder()
                .MsmqSubscriptionStorage()
                .XmlSerializer().MsmqTransport()
                .IsTransactional(True).PurgeOnStartup(False)
                .UnicastBus()
                .ImpersonateSender(False)
                .CreateBus()
                .Start()

<span style="color: #008000;">#create some messages</span>
msg1 = EventMessage()
msg1.EventId = Guid.NewGuid()
msg1.Duration = TimeSpan(99999)
msg1.Time = DateTime.Now 

msg2 = EventMessage()
msg2.EventId = Guid.NewGuid()
msg2.Duration = TimeSpan(99999)
msg2.Time = DateTime.Now.AddYears(-1)

<span style="color: #008000;">#prove that the messages have values</span>
print msg1.EventId.ToString()
print msg2.EventId.ToString()

<span style="color: #008000;">#put the messages in an array </span>
msgs = Array[EventMessage]((msg1, msg2))

<span style="color: #008000;">#publish the messages</span>
bus.Publish[EventMessage](msgs)</pre>
</div>
<h3><span style="text-decoration: underline;">Running the Code</span></h3>
<p>After running this script above we can expect our subscribers to start receiving the messages and we can check to see if indeed the Guid and DateTime property values in the messages match up once being received by the subscribers.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2009/07/iron-bus-subscriber.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="click to see full size" src="http://www.simonsegal.net/blog/wp-content/uploads/2009/07/iron-bus-subscriber-thumb.png" border="0" alt="click to see full size" width="476" height="260" /></a></p>
<p>As you can see, our EventId values and other properties all match those created using a <a href="http://en.wikipedia.org/wiki/Read-eval-print_loop" target="_blank">REPL</a> experience with IronPython embedded as our publisher. The Dynamic languages turn out to be useful in other places when it comes to <a href="http://www.nservicebus.com/" target="_blank">NServiceBus</a> but we will leave that for another post soon.</p>
<p>Also, I would like to point out that you could leave the configuration code in the C# code that starts up the publisher and push the IBus instance as a variable into the scope of the IronPython runtime and then execute a similar (smaller) script against it. <a href="http://www.simonsegal.net/blog/2009/07/01/an-ironpython-repl-console-in-a-wpf-user-control/" target="_blank">The IronPython Application Shell</a> has a method that allows you to add variables into the scope ad-hoc from the statically typed side of the publisher. Here’s how to achieve that:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">[STAThread]
<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> Main()
{
    LogManager.GetLogger(<span style="color: #006080;">&#8220;hello&#8221;</span>).Debug(<span style="color: #006080;">&#8220;Started.&#8221;</span>);

    bus = NServiceBus.Configure.With()
        .SpringBuilder()
        .MsmqSubscriptionStorage()
        .XmlSerializer()
        .MsmqTransport()
            .IsTransactional(<span style="color: #0000ff;">true</span>)
            .PurgeOnStartup(<span style="color: #0000ff;">false</span>)
        .UnicastBus()
            .ImpersonateSender(<span style="color: #0000ff;">false</span>)
        .CreateBus()
        .Start();

    var ir_window = <span style="color: #0000ff;">new</span> ConsoleWindow();

    var vars = <span style="color: #0000ff;">new</span> Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">object</span>&gt;();
    vars.Add(<span style="color: #006080;">&#8220;bus&#8221;</span>, bus);
    ir_window.ctlIronPythonConsole.OnVariablesAdded(vars);

    ir_window.Title = <span style="color: #006080;">&#8220;NServiceBus IronPython Publisher&#8221;</span>;
    ir_window.ShowDialog();
}</pre>
</div>
<p>You can find the full code here and if your interested in downloading <a href="http://www.simonsegal.net/blog/2009/07/01/an-ironpython-repl-console-in-a-wpf-user-control/" target="_blank">The IronPython Application Shell</a>, it can be found <a href="http://simonsegal.net/TechAPublicRepo/Trunk/WpfIronPythonConsole" target="_blank">here</a>.</p>
<p>Below is the link to the full sample including the the NServiceBus PubSub sample, however you should remember to setup the queues that are required (by the NServiceBus samples themselves) by running the <strong>VbScript</strong> that comes with the <a href="http://sourceforge.net/projects/nservicebus/files/" target="_blank">download</a> of NServiceBus itself.</p>
<p><a href="http://simonsegal.net/TechAPublicRepo/Trunk/IronPythonPubSub" target="_blank">NServiceBus-Pub/Sub Example with IronPython Application Shell</a></p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Configuring%2C%20Testing%20and%20Probing%20NServiceBus%20with%20IronPython&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F07%2F06%2Fconfiguring-testing-and-probing-nservicebus-with-ironpython%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Configuring, Testing and Probing NServiceBus with IronPython";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/07/06/configuring-testing-and-probing-nservicebus-with-ironpython/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=nqVtl6kn7aQ:KEIwrSpGHUU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=nqVtl6kn7aQ:KEIwrSpGHUU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=nqVtl6kn7aQ:KEIwrSpGHUU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=nqVtl6kn7aQ:KEIwrSpGHUU:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=nqVtl6kn7aQ:KEIwrSpGHUU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=nqVtl6kn7aQ:KEIwrSpGHUU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=nqVtl6kn7aQ:KEIwrSpGHUU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=nqVtl6kn7aQ:KEIwrSpGHUU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=nqVtl6kn7aQ:KEIwrSpGHUU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=nqVtl6kn7aQ:KEIwrSpGHUU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=nqVtl6kn7aQ:KEIwrSpGHUU:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/nqVtl6kn7aQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/07/06/configuring-testing-and-probing-nservicebus-with-ironpython/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/07/06/configuring-testing-and-probing-nservicebus-with-ironpython/</feedburner:origLink></item>
		<item>
		<title>Firefox annoyance – rare but true</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/2Ric1hEPu5g/</link>
		<comments>http://www.simonsegal.net/blog/2009/07/03/firefox-annoyance-rare-but-true/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 12:03:39 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[Browsers]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/07/03/firefox-annoyance-rare-but-true/</guid>
		<description><![CDATA[I have been a Firefox fan for a couple of versions now but I cant believe this really annoying great feature in the latest version (3.5) of Firefox. If I hover over any part of a page, it displays an empty tooltip.
It’s hardly a feature that gets in your way but it’s damn annoying. Even [...]]]></description>
			<content:encoded><![CDATA[<p>I have been a Firefox fan for a couple of versions now but I cant<a href="http://www.simonsegal.net/blog/wp-content/uploads/2009/07/firefox-tooltip-nuts.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="firefox_tooltip_nuts" src="http://www.simonsegal.net/blog/wp-content/uploads/2009/07/firefox-tooltip-nuts-thumb.png" border="0" alt="firefox_tooltip_nuts" width="162" height="197" align="left" /></a> believe this really <span style="text-decoration: line-through;">annoying</span> great feature in the latest version (3.5) of Firefox. If I hover over any part of a page, it displays an empty tooltip.</p>
<p>It’s hardly a feature that gets in your way but it’s damn annoying. Even if I hover over the vertical scrollbar I can see the damn thing. Apparently there has been some history of <a href="http://blog.borngeek.com/2007/09/14/firefox-title-tooltip-bug/" target="_blank">tooltip strangeness</a> with Firefox in the <a href="http://ubuntuforums.org/showthread.php?t=840282" target="_blank">past</a> but I haven’t really delved into it too deeply.</p>
<p>Anyone heard of this problem before or experiencing it with the current version?</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Firefox%20annoyance%20%26ndash%3B%20rare%20but%20true&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F07%2F03%2Ffirefox-annoyance-rare-but-true%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Firefox annoyance &ndash; rare but true";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/07/03/firefox-annoyance-rare-but-true/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=2Ric1hEPu5g:2sMvXY0nLIA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=2Ric1hEPu5g:2sMvXY0nLIA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=2Ric1hEPu5g:2sMvXY0nLIA:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=2Ric1hEPu5g:2sMvXY0nLIA:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=2Ric1hEPu5g:2sMvXY0nLIA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=2Ric1hEPu5g:2sMvXY0nLIA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=2Ric1hEPu5g:2sMvXY0nLIA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=2Ric1hEPu5g:2sMvXY0nLIA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=2Ric1hEPu5g:2sMvXY0nLIA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=2Ric1hEPu5g:2sMvXY0nLIA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=2Ric1hEPu5g:2sMvXY0nLIA:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/2Ric1hEPu5g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/07/03/firefox-annoyance-rare-but-true/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/07/03/firefox-annoyance-rare-but-true/</feedburner:origLink></item>
		<item>
		<title>NServiceBus has made messaging an easier choice.</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/p1Y8FgKW7Ww/</link>
		<comments>http://www.simonsegal.net/blog/2009/07/02/nservicebus-has-made-messaging-an-easier-choice/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 22:07:55 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[NServiceBus]]></category>

		<category><![CDATA[SOA]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/07/02/nservicebus-has-made-messaging-an-easier-choice/</guid>
		<description><![CDATA[I am finding it harder and harder to find scenarios where I would consider anything other than NServiceBus to build messaging systems behind the corporate firewall. Certainly punching a hole through it might open up the possibility for other technologies, but in most cases it’s to act as a bridge to what will eventually hit [...]]]></description>
			<content:encoded><![CDATA[<p>I am finding it harder and harder to find scenarios where I would consider anything other than <a href="http://www.nservicebus.com/">NServiceBus</a> to build messaging systems behind the corporate firewall. Certainly punching a hole through it might open up the possibility for other technologies, but in most cases it’s to act as a bridge to what will eventually hit some NServiceBus infrastructure.</p>
<p>Deployment is a snap and in a project based environment where small systems are regularly custom built to order for heavy load batch processing, NServiceBus will make rolling out a highly scalable solution a very quick and reasonably simple process. Also, NServiceBus configuration is far simpler these days and to be honest, compared to some frameworks it’s downright simple to understand.</p>
<p>The kind of processing numbers we are achieving in current proof of concepts for new projects are impressive and the deployment story is going to let us ring out every last drop of blood from hardware otherwise considered as redundant and useless. Not a web server in sight!</p>
<p>One thing on <span style="text-decoration: line-through;"><strong><em>MY</em></strong></span> the Network Administrators wish list is a zero deployment transactional queue (transport). Andreas created a <a href="http://andreasohlund.blogspot.com/2007/07/filebased-transport-for-nbus.html" target="_blank">file based ITransport</a> implementation but unfortunately no support for transactions, however it does show just how extensible NServiceBus is.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=NServiceBus%20has%20made%20messaging%20an%20easier%20choice.&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F07%2F02%2Fnservicebus-has-made-messaging-an-easier-choice%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="NServiceBus has made messaging an easier choice.";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/07/02/nservicebus-has-made-messaging-an-easier-choice/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=p1Y8FgKW7Ww:KhrZ5UXqDC0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=p1Y8FgKW7Ww:KhrZ5UXqDC0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=p1Y8FgKW7Ww:KhrZ5UXqDC0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=p1Y8FgKW7Ww:KhrZ5UXqDC0:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=p1Y8FgKW7Ww:KhrZ5UXqDC0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=p1Y8FgKW7Ww:KhrZ5UXqDC0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=p1Y8FgKW7Ww:KhrZ5UXqDC0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=p1Y8FgKW7Ww:KhrZ5UXqDC0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=p1Y8FgKW7Ww:KhrZ5UXqDC0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=p1Y8FgKW7Ww:KhrZ5UXqDC0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=p1Y8FgKW7Ww:KhrZ5UXqDC0:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/p1Y8FgKW7Ww" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/07/02/nservicebus-has-made-messaging-an-easier-choice/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/07/02/nservicebus-has-made-messaging-an-easier-choice/</feedburner:origLink></item>
		<item>
		<title>An IronPython REPL Console in a WPF User Control</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/GvphAhDwZNE/</link>
		<comments>http://www.simonsegal.net/blog/2009/07/01/an-ironpython-repl-console-in-a-wpf-user-control/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 21:41:06 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[DLR]]></category>

		<category><![CDATA[IronPython]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/07/01/an-ironpython-repl-console-in-a-wpf-user-control/</guid>
		<description><![CDATA[Recently I posted an IronRuby Console, purpose built as a WPF user control. The basic reasoning was to allow me drop in scripting into any given application or User Interface. In more recent times (with some help from Michael) I decided to ‘jump ships’ and move to IronPython as my choice DLR language. Given the [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I posted an <a href="http://www.simonsegal.net/blog/2009/05/30/a-wpf-ironruby-scripting-console-user-control/" target="_blank">IronRuby Console</a>, purpose built as a WPF user control. The basic reasoning was to allow me drop in scripting into any given application or User Interface. In more recent times (<a href="http://ironpython-urls.blogspot.com/2009/06/choosing-dlr-language-ironpython-or.html" target="_blank">with some help from Michael</a>) I decided to ‘<a href="http://www.simonsegal.net/blog/2009/06/24/why-i-chose-ironpython-over-ironruby-in-the-end/" target="_blank">jump ships</a>’ and move to IronPython as my choice DLR language. Given the change in direction I was obviously going to need my console window to support the language of my choosing.</p>
<h3><span style="text-decoration: underline;">The New IronPython Version</span></h3>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2009/07/tipas-public-intro.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="tipas_public_intro" src="http://www.simonsegal.net/blog/wp-content/uploads/2009/07/tipas-public-intro-thumb.png" border="0" alt="tipas_public_intro" width="483" height="479" /></a></p>
<p>So to move forward with the WPF user control console project I decided to refactor it to support IronPython. <a href="http://www.markharris.net.au" target="_blank">Mark</a> has jumped in just recently and started to contribute by adding the new “<strong><em>cached commands</em></strong>”, which offer <em>up / down</em> arrow repeat command behaviour such as found on a DOS console. You will also notice from the screenshot above I have imported the entire System namespace to demonstrate that it is possible (<em><strong>using the environment menu</strong></em>) to print the entire state of the default scopes current set of variables.</p>
<p>Now it’s true I could have done this in a way that allowed for switching between the languages, however I have delayed that decision until IronRuby reaches it’s version 1.0 official release. In the meantime you can now use the IronPython version or the IronRuby Version seperately.</p>
<p>I am going to follow up shortly with an example of how this little window can be become quite useful in a practical way.</p>
<h3><span style="text-decoration: underline;">Downloads</span></h3>
<p><a href="http://simonsegal.net/TechAPublicRepo/Trunk/WpfIronPythonConsole" target="_blank">IronPython Console Window Project</a></p>
<p><a href="http://simonsegal.net/TechAPublicRepo/Trunk/WpfIronRubyConsole" target="_blank">IronRuby Console Window Project</a></p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=An%20IronPython%20REPL%20Console%20in%20a%20WPF%20User%20Control&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F07%2F01%2Fan-ironpython-repl-console-in-a-wpf-user-control%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="An IronPython REPL Console in a WPF User Control";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/07/01/an-ironpython-repl-console-in-a-wpf-user-control/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=GvphAhDwZNE:-_oNmWksgBI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=GvphAhDwZNE:-_oNmWksgBI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=GvphAhDwZNE:-_oNmWksgBI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=GvphAhDwZNE:-_oNmWksgBI:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=GvphAhDwZNE:-_oNmWksgBI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=GvphAhDwZNE:-_oNmWksgBI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=GvphAhDwZNE:-_oNmWksgBI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=GvphAhDwZNE:-_oNmWksgBI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=GvphAhDwZNE:-_oNmWksgBI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=GvphAhDwZNE:-_oNmWksgBI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=GvphAhDwZNE:-_oNmWksgBI:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/GvphAhDwZNE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/07/01/an-ironpython-repl-console-in-a-wpf-user-control/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/07/01/an-ironpython-repl-console-in-a-wpf-user-control/</feedburner:origLink></item>
		<item>
		<title>No REST from reading!</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/7DMph-8KgUY/</link>
		<comments>http://www.simonsegal.net/blog/2009/06/25/no-rest-from-reading/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 10:28:40 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[IronPython]]></category>

		<category><![CDATA[NServiceBus]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/06/25/no-rest-from-reading/</guid>
		<description><![CDATA[I just received IronPython In Action and cant wait to tear into it, I just have to get RESTful.Net off the bedside table and I’m good to go. Not since NServiceBus fell across my path have I been this excited (not that I am comparing them). If only there was a book on NServiceBus? Udi [...]]]></description>
			<content:encoded><![CDATA[<p>I just received <a href="http://www.manning.com/foord/" target="_blank">IronPython In Action</a> and cant wait to tear into it, I just have to get <a href="http://oreilly.com/catalog/9780596519209" target="_blank">RESTful.Net</a> off the bedside table and I’m good to go. Not since <a href="http://www.nservicebus.com/" target="_blank">NServiceBus</a> fell across my path have I been this excited (not that I am comparing them). If only there was a book on NServiceBus? <a href="http://www.udidahan.com/" target="_blank">Udi</a> what say thou? The world is ready for it…</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=No%20REST%20from%20reading%21&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F06%2F25%2Fno-rest-from-reading%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="No REST from reading!";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/06/25/no-rest-from-reading/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=7DMph-8KgUY:2sCTa3XRfc4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=7DMph-8KgUY:2sCTa3XRfc4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=7DMph-8KgUY:2sCTa3XRfc4:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=7DMph-8KgUY:2sCTa3XRfc4:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=7DMph-8KgUY:2sCTa3XRfc4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=7DMph-8KgUY:2sCTa3XRfc4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=7DMph-8KgUY:2sCTa3XRfc4:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=7DMph-8KgUY:2sCTa3XRfc4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=7DMph-8KgUY:2sCTa3XRfc4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=7DMph-8KgUY:2sCTa3XRfc4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=7DMph-8KgUY:2sCTa3XRfc4:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/7DMph-8KgUY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/06/25/no-rest-from-reading/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/06/25/no-rest-from-reading/</feedburner:origLink></item>
		<item>
		<title>Why I chose IronPython over IronRuby in the end.</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/kVLHhiF1RcE/</link>
		<comments>http://www.simonsegal.net/blog/2009/06/24/why-i-chose-ironpython-over-ironruby-in-the-end/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 12:33:45 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[IronPython]]></category>

		<category><![CDATA[IronRuby]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/06/24/why-i-chose-ironpython-over-ironruby-in-the-end/</guid>
		<description><![CDATA[Initially when I made the decision that I would benefit from learning a new language that adhered to a different paradigm (dynamically typed), I selected IronRuby over IronPython simply because I had seen it first and perhaps got caught up a little in the industry hype and good PR going on.
After having spent a less [...]]]></description>
			<content:encoded><![CDATA[<p>Initially when I made the decision that I would benefit from learning a new language that adhered to a different paradigm (dynamically typed), I selected IronRuby over IronPython simply because I had seen it first and perhaps got caught up a little in the industry hype and good PR going on.</p>
<p>After having spent a less than insignificant amount of time invested in IronRuby I decided to bite the bullet and invest the effort into IronPython instead and the reasons were entirely pragmatic. Microsoft <em><strong>seem</strong></em> to be putting more effort into IronPython, has already found it’s way into other stacks, such as Oslo’s Intellipad (which I plan to leverage) and it’s significantly more mature than IronRuby.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2009/06/netbeans-ip-setup.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="netbeans_ip_setup" src="http://www.simonsegal.net/blog/wp-content/uploads/2009/06/netbeans-ip-setup-thumb.png" border="0" alt="netbeans_ip_setup" width="442" height="321" /></a></p>
<p>I am constantly finding uses for IronPython in my work and the list of problems that it’s going to help solve is growing quickly. As a side note, if you are looking to use IronPython and are ready to let the experience pass you by because of lack of IDE support then check out using <a href="http://www.netbeans.org/features/python/" target="_blank">NetBeans</a> (for Python) and instead using IronPython. As previously detailed by <a href="http://stevegilham.blogspot.com/2009/05/using-ironpython-with-netbeans-python.html" target="_blank">Steven and David</a>, you can use the NetBeans Tools menu and make the selection ‘<strong><em>Python Platforms</em></strong>’, then you can configure a new default platform setting and redirect the IDE to use IronPython (see above screenshot). I haven’t used this configuration for long but for now it seems to work nicely.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Why%20I%20chose%20IronPython%20over%20IronRuby%20in%20the%20end.&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F06%2F24%2Fwhy-i-chose-ironpython-over-ironruby-in-the-end%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Why I chose IronPython over IronRuby in the end.";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/06/24/why-i-chose-ironpython-over-ironruby-in-the-end/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=kVLHhiF1RcE:xMH5CRYAV8w:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=kVLHhiF1RcE:xMH5CRYAV8w:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=kVLHhiF1RcE:xMH5CRYAV8w:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=kVLHhiF1RcE:xMH5CRYAV8w:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=kVLHhiF1RcE:xMH5CRYAV8w:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=kVLHhiF1RcE:xMH5CRYAV8w:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=kVLHhiF1RcE:xMH5CRYAV8w:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=kVLHhiF1RcE:xMH5CRYAV8w:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=kVLHhiF1RcE:xMH5CRYAV8w:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=kVLHhiF1RcE:xMH5CRYAV8w:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=kVLHhiF1RcE:xMH5CRYAV8w:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/kVLHhiF1RcE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/06/24/why-i-chose-ironpython-over-ironruby-in-the-end/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/06/24/why-i-chose-ironpython-over-ironruby-in-the-end/</feedburner:origLink></item>
		<item>
		<title>Which DLR language should I choose? Is it now IronRuby vs. IronPython.</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/QUCk-iv7uVQ/</link>
		<comments>http://www.simonsegal.net/blog/2009/06/18/which-dlr-language-should-i-choose-is-it-now-ironruby-vs-ironpython/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 12:40:22 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[IronPython]]></category>

		<category><![CDATA[IronRuby]]></category>

		<category><![CDATA[Languages]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/06/18/which-dlr-language-should-i-choose-is-it-now-ironruby-vs-ironpython/</guid>
		<description><![CDATA[This post is not about creating a language zealot’s war – let me make that absolutely clear from the outset. What this post is about is a question, how does one go about making their minds up in choosing a language for developing in the dynamic world of the DLR?
For my part so far I [...]]]></description>
			<content:encoded><![CDATA[<p>This post is not about creating a language zealot’s war – let me make that absolutely clear from the outset. What this post is about is a question, how does one go about making their minds up in choosing a language for developing in the dynamic world of the DLR?</p>
<p>For my part so far I have <a href="http://www.simonsegal.net/blog/tag/ironruby/" target="_blank">delved</a> into IronRuby and started to employ it for <a href="http://www.simonsegal.net/blog/2009/04/18/entity-framework-profiler-with-ironruby-and-ironpython-scripting/" target="_blank">scripting my C# applications</a>. Why did I choose IronRuby over IronPython? It began with curiosity in the Ruby language in general and led inevitably to IronRuby. I quickly acquired a taste for Ruby but there is something nagging in the back of my mind and I can’t get to the bottom of it - “<strong><em>did I choose the right language</em></strong>” and really after all “<strong><em>does it matter which one I choose?</em></strong>”</p>
<p>Given Pythons relationship to C and my emotional connection to the C family of languages, would IronPython have been a better choice? Certainly IronPython is further down the track and more mature than IronRuby at this stage, but what does that count for at this early stage? All these questions make me curious for some other opinions which I would leave to hear right here, so please tell me – what do you think? What criteria would you use to make a choice?</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Which%20DLR%20language%20should%20I%20choose%3F%20Is%20it%20now%20IronRuby%20vs.%20IronPython.&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F06%2F18%2Fwhich-dlr-language-should-i-choose-is-it-now-ironruby-vs-ironpython%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Which DLR language should I choose? Is it now IronRuby vs. IronPython.";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/06/18/which-dlr-language-should-i-choose-is-it-now-ironruby-vs-ironpython/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=QUCk-iv7uVQ:l4xHw4BLMNU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=QUCk-iv7uVQ:l4xHw4BLMNU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=QUCk-iv7uVQ:l4xHw4BLMNU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=QUCk-iv7uVQ:l4xHw4BLMNU:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=QUCk-iv7uVQ:l4xHw4BLMNU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=QUCk-iv7uVQ:l4xHw4BLMNU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=QUCk-iv7uVQ:l4xHw4BLMNU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=QUCk-iv7uVQ:l4xHw4BLMNU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=QUCk-iv7uVQ:l4xHw4BLMNU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=QUCk-iv7uVQ:l4xHw4BLMNU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=QUCk-iv7uVQ:l4xHw4BLMNU:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/QUCk-iv7uVQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/06/18/which-dlr-language-should-i-choose-is-it-now-ironruby-vs-ironpython/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/06/18/which-dlr-language-should-i-choose-is-it-now-ironruby-vs-ironpython/</feedburner:origLink></item>
		<item>
		<title>Entity Framework, Fluent Interfaces &amp; Domain Specific Languages Part 2</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/h7BoCpTdk44/</link>
		<comments>http://www.simonsegal.net/blog/2009/06/17/entity-framework-fluent-interfaces-domain-specific-languages-part-2/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 20:42:56 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[DSL]]></category>

		<category><![CDATA[Entity Framework]]></category>

		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/06/17/entity-framework-fluent-interfaces-domain-specific-languages-part-2/</guid>
		<description><![CDATA[In the first part of this series I looked at how you might go about building an (incredibly tiny) domain specific language for analysing data. The context I gave was a scenario where project managers were required to work with a continuous stream of data in the form of a known schema. This ‘known’ schema [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://www.simonsegal.net/blog/2009/05/24/entity-framework-fluent-interfaces-domain-specific-languages/" target="_blank">first part of this series</a> I looked at how you might go about building an (incredibly tiny) domain specific language for analysing data. The context I gave was a scenario where project managers were required to work with a continuous stream of data in the form of a known schema. This <strong><em>‘known’</em></strong> schema is most commonly used in moving and transforming data between various systems in a domain where the central or end target is a Document Management System. The ‘<strong><em>known</em></strong>’ schema is an agreed format that all systems in this particular industry use to extract and subsequently load. It is common to see the project managers struggling with tools like access to compose queries to analyse the data before or after these ETL processes and hence proposition of a DSL.</p>
<p>In the first part I wasn’t particularly happy with the underlying behaviour of the language statements; we were producing a cascading set of queries, rather than composing a query structure. This time around we look to achieve this compositional affect with a fluent interface that issues a beginning statement and subsequently composes a query until a finalizing command is submitted to indicate that execution should take place against the database. If we use <a href="http://www.simonsegal.net/blog/2009/01/13/entity-framework-repository-specifications-and-fetching-strategies/" target="_blank">Specifications</a> to compose the predicates in querying the database we can achieve the composition through chaining extension methods and thus build up an execution context from the syntax in our language.</p>
<p>Consider this fluent interface:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> prints_order_lines_grouped_by_customer_and_orders()
{
    NorthwindLangQuery
    .BeginQuery()
    .Customers()
    .With_An_Id_Equal_To(<span style="color: #006080;">&#8220;ALFKI&#8221;</span>)
    .With_Orders_Shipped_From(<span style="color: #006080;">&#8220;Germany&#8221;</span>)
    .That()
    .Are()
    .Older_In_Years_By(2)
    .EndCustomerQuery()
    .Print_Customer_Orders_To_Console_Window();
}</pre>
</div>
<div>which produces the following output:</div>
<div><span style="color: #ff8040;">Order ID: ALFKI</span></div>
<div><strong><span style="color: #800040;">10643</span></strong></div>
<div><span style="color: #008000;">Product ID 28 x 15 units @ total cost = 683.8500 </span></div>
<div><span style="color: #008000;">Product ID 39 x 21 units @ total cost = 377.8500 </span></div>
<div><span style="color: #008000;">Product ID 46 x 2 units @ total cost = 23.8500</span></div>
<div><strong><span style="color: #800040;">10692</span></strong></div>
<div><span style="color: #008000;">Product ID 63 x 20 units @ total cost = 877.8500</span></div>
<div><strong><span style="color: #800040;">10702</span></strong></div>
<div><span style="color: #008000;">Product ID 3 x 6 units @ total cost = 59.8500 </span></div>
<div><span style="color: #008000;">Product ID 76 x 15 units @ total cost = 269.8500</span></div>
<div><strong><span style="color: #800040;">10835</span></strong></div>
<div><span style="color: #008000;">Product ID 59 x 15 units @ total cost = 824.8500 </span></div>
<div><span style="color: #008000;">Product ID 77 x 2 units @ total cost = 25.8500</span></div>
<div><strong><span style="color: #800040;">10952</span></strong></div>
<div><span style="color: #008000;">Product ID 6 x 16 units @ total cost = 399.8500 </span></div>
<div><span style="color: #008000;">Product ID 28 x 2 units @ total cost = 91.0500</span></div>
<div><strong><span style="color: #800040;">11011</span></strong></div>
<div><span style="color: #008000;">Product ID 58 x 40 units @ total cost = 529.8500 </span></div>
<p>Instead of cascading sub queries that work on an initial database query as with the code shown in <a href="http://www.simonsegal.net/blog/2009/05/24/entity-framework-fluent-interfaces-domain-specific-languages/" target="_blank">part 1</a>, we use the specification pattern to build up predicates that we submit with a single SQL (LINQ To Entities) query to the database. If we pull apart the NorthwindLang query above and follow it method by method here is what it looks like:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> NorthwindLang BeginQuery()
{
    _customerSpec =
        <span style="color: #0000ff;">new</span> Specification&lt;Customer&gt;(c =&gt; c == c);

    _orderSpec =
        <span style="color: #0000ff;">new</span> Specification&lt;Order&gt;(o =&gt; o == o);

    _orderLineSpec =
        <span style="color: #0000ff;">new</span> Specification&lt;OrderLine&gt;(ol =&gt; ol == ol);
    <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">new</span> NorthwindLang();
}</pre>
</div>
<p>The <strong><em>BeginQuery()</em></strong> method simply primes each of our specifications which progressively are built upon in the following chained method calls.</p>
<p>No change required in the method body below as we already know we are dealing with a customer.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Specification&lt;Customer&gt; Customers(<span style="color: #0000ff;">this</span> NorthwindLang query)
{
    <span style="color: #0000ff;">return</span> _customerSpec;
}</pre>
</div>
<p>Next the specification has a filtering expression to the customer ID appended using the logical AND operator.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Specification&lt;Customer&gt; With_An_Id_Equal_To
            (<span style="color: #0000ff;">this</span> Specification&lt;Customer&gt; customers, <span style="color: #0000ff;">string</span> id)
{
    var cust_id_spec =
        <span style="color: #0000ff;">new</span> Specification&lt;Customer&gt;(c =&gt; c.CustomerID == id);
    _customerSpec &amp;= cust_id_spec;
    <span style="color: #0000ff;">return</span> _customerSpec;
}</pre>
</div>
<p>The customer orders are also required in the query so we are going to need to setup the Orders specification with it’s required predicate.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Specification&lt;Order&gt; With_Orders_Shipped_From
            (<span style="color: #0000ff;">this</span> Specification&lt;Customer&gt; customers, <span style="color: #0000ff;">string</span> country)
{
    Specification&lt;Order&gt; order_shipcountry_spec =
        <span style="color: #0000ff;">new</span> Specification&lt;Order&gt;(o =&gt; o.ShipCountry == country);
    _orderSpec &amp;= order_shipcountry_spec;
    <span style="color: #0000ff;">return</span> _orderSpec;
}</pre>
</div>
<p>The next two parts of the query are benign and have no effect on the composition of the query and only play a part in providing a more natural syntax composition for the language.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Specification&lt;Order&gt; That
            (<span style="color: #0000ff;">this</span> Specification&lt;Order&gt; orders)
{
    <span style="color: #0000ff;">return</span> _orderSpec;
}

<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Specification&lt;Order&gt; Are
    (<span style="color: #0000ff;">this</span> Specification&lt;Order&gt; orders)
{
    <span style="color: #0000ff;">return</span> _orderSpec;
}</pre>
</div>
<p>Next we add a further Orders specification limiting the result set to orders more than twelve years old.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Specification&lt;Order&gt; Older_In_Years_By
            (<span style="color: #0000ff;">this</span> Specification&lt;Order&gt; orders, <span style="color: #0000ff;">int</span> age)
{
    var date = DateTime.Now.AddYears(-age);
    Specification&lt;Order&gt; order_older_spec =
        <span style="color: #0000ff;">new</span> Specification&lt;Order&gt;(o =&gt; o.OrderDate &lt; date);
    <span style="color: #0000ff;">return</span> _orderSpec &amp;= order_older_spec;
}</pre>
</div>
<p>Finally we demarcate the end of the query by calling one of the finalization methods that can only be followed by subsequent printing methods.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> IEnumerable&lt;LangDomain.Customer&gt;
    EndCustomerQuery(<span style="color: #0000ff;">this</span> Specification&lt;Order&gt; orders)
{
    <span style="color: #0000ff;">return</span> DomainQuery&lt;LangDomain.Customer&gt;
        .CreateQuery(_customerSpec, _orderSpec);
}</pre>
</div>
<p>This is still all proof of concept stuff and I plan to follow up with putting a harness together with the Fireball code editor API. Here is a further list of some of the other language statements that the fluent interface is capable of producing at the time of this writing.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> prints_order_lines_grouped_by_customer_and_orders()
{
    NorthwindLangQuery
        .BeginQuery()
        .Customers()
        .With_An_Id_Equal_To(<span style="color: #006080;">&#8220;ALFKI&#8221;</span>)
        .With_Orders_Shipped_From(<span style="color: #006080;">&#8220;Germany&#8221;</span>)
        .That()
        .Are()
        .Older_In_Years_By(2)
        .EndCustomerQuery()
        .Print_Customer_Orders_To_Console_Window();
}

<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> selects_customers_by_id()
{
    var cust = NorthwindLangQuery
        .BeginQuery()
        .Customers()
        .With_An_Id_Equal_To(<span style="color: #006080;">&#8220;ALFKI&#8221;</span>)
        .EndCustomerQuery()
        .As_Unique_Where_Customers_Ids_Are_The_Same();

    <span style="color: #0000ff;">foreach</span> (var c <span style="color: #0000ff;">in</span> cust)
    {
        Console.WriteLine(c.CompanyName);
    }
}

<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> selects_orders_specified_by_age_of_orders_with_
    specified_freight_costs()
{
    var query = NorthwindLangQuery
        .BeginQuery()
        .Orders()
        .Older_In_Years_By(12)
        .With()
        .Freight_Costs_More_Than(360)
        .EndOrderQuery();

    <span style="color: #0000ff;">foreach</span> (var o <span style="color: #0000ff;">in</span> query)
    {
        <span style="color: #0000ff;">foreach</span> (var ol <span style="color: #0000ff;">in</span> o.Order_Details)
        {
            Console.WriteLine(o.OrderID +
                <span style="color: #006080;">&#8221; : &#8220;</span> + o.Freight +
                <span style="color: #006080;">&#8221; : &#8220;</span> + ol.ProductID);
        }
    }
}

<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> selects_customers_by_id_for_advanced_users()
{
    var cust = NorthwindLangQuery
        .BeginQuery()
        .Customers()
        .EndCustomerQuery()
        .As_Unique_Where((cLeft, cRight) =&gt;
            cLeft.CustomerID == cRight.CustomerID);

    <span style="color: #0000ff;">foreach</span> (var c <span style="color: #0000ff;">in</span> cust)
    {
        Console.WriteLine(c.CompanyName);
    }
}</pre>
</div>
<p>You can download the entire source code from the <a href="http://simonsegal.net/TechAPublicRepo/Trunk/EntityFrameWorkDataDsl" target="_blank">repository here</a>.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Entity%20Framework%2C%20Fluent%20Interfaces%20%26%20Domain%20Specific%20Languages%20Part%202&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F06%2F17%2Fentity-framework-fluent-interfaces-domain-specific-languages-part-2%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Entity Framework, Fluent Interfaces & Domain Specific Languages Part 2";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/06/17/entity-framework-fluent-interfaces-domain-specific-languages-part-2/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=h7BoCpTdk44:GTMl7R4SwNI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=h7BoCpTdk44:GTMl7R4SwNI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=h7BoCpTdk44:GTMl7R4SwNI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=h7BoCpTdk44:GTMl7R4SwNI:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=h7BoCpTdk44:GTMl7R4SwNI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=h7BoCpTdk44:GTMl7R4SwNI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=h7BoCpTdk44:GTMl7R4SwNI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=h7BoCpTdk44:GTMl7R4SwNI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=h7BoCpTdk44:GTMl7R4SwNI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=h7BoCpTdk44:GTMl7R4SwNI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=h7BoCpTdk44:GTMl7R4SwNI:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/h7BoCpTdk44" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/06/17/entity-framework-fluent-interfaces-domain-specific-languages-part-2/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/06/17/entity-framework-fluent-interfaces-domain-specific-languages-part-2/</feedburner:origLink></item>
		<item>
		<title>Type Member Name Resolution with Functions – Part 2.0</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/fb2lRUwhfNA/</link>
		<comments>http://www.simonsegal.net/blog/2009/06/16/type-member-name-resolution-with-functions-part-20/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 21:28:10 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/06/16/type-member-name-resolution-with-functions-part-20/</guid>
		<description><![CDATA[Adding to the previous post, the PropertyNameResolver class needs to expand it&#8217;s horizons and resolve method names and field names. Given the expanded requirement we probably need to refactor the name of the class to something more appropriate. Here is a more fleshed out idea of what it might look like:

public class MemberNameResolver&#60;T&#62;
{
   [...]]]></description>
			<content:encoded><![CDATA[<p>Adding to the <a href="http://www.simonsegal.net/blog/2009/06/11/functional-type-member-resolution-with-c/" target="_blank">previous post</a>, the <em><strong>PropertyNameResolver </strong></em>class needs to expand it&#8217;s horizons and resolve method names and field names. Given the expanded requirement we probably need to refactor the name of the class to something more appropriate. Here is a more fleshed out idea of what it might look like:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> MemberNameResolver&lt;T&gt;
{
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> ResolveProperty&lt;TPropertyType&gt;
        (Expression&lt;Func&lt;T, TPropertyType&gt;&gt; expression)
    {
        Func&lt;Expression&lt;Func&lt;T, TPropertyType&gt;&gt;, <span style="color: #0000ff;">string</span>&gt;
            prop_name_function = l =&gt;
        {
            <span style="color: #0000ff;">return</span> GetNameFromExpression(l.Body);
        };
        var property_name =
            <span style="color: #0000ff;">typeof</span>(T).GetProperty(prop_name_function(expression)).Name;
        <span style="color: #0000ff;">return</span> property_name;
    }

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> ResolveMethod(Expression&lt;Action&lt;T&gt;&gt; expression)
    {
        Func&lt;Expression&lt;Action&lt;T&gt;&gt;, <span style="color: #0000ff;">string</span>&gt;
            prop_name_function = l =&gt;
            {
                <span style="color: #0000ff;">return</span> GetNameFromExpression(l.Body);
            };
        var property_name =
            <span style="color: #0000ff;">typeof</span>(T).GetMethod(prop_name_function(expression)).Name;
        <span style="color: #0000ff;">return</span> property_name;
    }

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> ResolveField&lt;TPropertyType&gt;
        (Expression&lt;Func&lt;T, TPropertyType&gt;&gt; expression)
    {
        Func&lt;Expression&lt;Func&lt;T, TPropertyType&gt;&gt;, <span style="color: #0000ff;">string</span>&gt;
            prop_name_function = l =&gt;
            {
                <span style="color: #0000ff;">return</span> GetNameFromExpression(l.Body);
            };
        var property_name =
            <span style="color: #0000ff;">typeof</span>(T).GetField(prop_name_function(expression)).Name;
        <span style="color: #0000ff;">return</span> property_name;
    }

    <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> GetNameFromExpression(Expression body)
    {
        <span style="color: #0000ff;">if</span> (ExpressionType.MemberAccess == body.NodeType)
        {
            var memberExpr = (MemberExpression)body;
            <span style="color: #0000ff;">return</span> memberExpr.Member.Name;
        }
        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (ExpressionType.Call == body.NodeType)
        {
            var methodExpr = (MethodCallExpression)body;
            <span style="color: #0000ff;">return</span> methodExpr.Method.Name;
        }
        <span style="color: #0000ff;">else</span>
        {
            <span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> NotImplementedException(
                <span style="color: #0000ff;">string</span>.Format(<span style="color: #006080;">&#8220;Resolving names from expression types &#8220;</span> +
                <span style="color: #006080;">&#8220;of {0} is not implemented!&#8221;</span>,
                body.Type.Name));
        }
    }
}</pre>
</div>
<div>Previously we did not account for method calls and as one <strong><em>kind soul</em></strong> articulately pointed out, the string manipulation was somewhat awkward. <a href="http://www.markharris.net.au" target="_blank">Mark</a> pointed out Damien’s <a href="http://www.shadow-angel.com/blog/2008/09/typesafe-reverse-reflection.html" target="_blank">neat solution</a> by way of digging into the expression body.</div>
<p>Notice the newly specialized Resolve methods now allow a usage like the following:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">var</span> member1 =
    MemberNameResolver&lt;Criteria&gt;
    .ResolveProperty&lt;<span style="color: #0000ff;">int</span>&gt;(c =&gt; c.PageCounter);
<span style="color: #0000ff;">var</span> member2 =
    MemberNameResolver&lt;Criteria&gt;
    .ResolveMethod(c =&gt; c.SomeMethod());
<span style="color: #0000ff;">var</span> member3 =
    MemberNameResolver&lt;Criteria&gt;
    .ResolveField(c =&gt; c.Percent);
<span style="color: #0000ff;">var</span> member4 =
    MemberNameResolver&lt;Criteria&gt;
    .ResolveMethod(c =&gt; c.SomeMethodWithArgs(<span style="color: #0000ff;">default</span>(<span style="color: #0000ff;">string</span>),
        <span style="color: #0000ff;">default</span>(<span style="color: #0000ff;">int</span>), <span style="color: #0000ff;">default</span>(<span style="color: #0000ff;">string</span>[])));

Console.WriteLine(member1);
Console.WriteLine(member2);
Console.WriteLine(member3);
Console.WriteLine(member4);</pre>
</div>
<p>Producing the following output:</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2009/06/console-functions-memer-resolve11.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="console_functions_memer_resolve1" src="http://www.simonsegal.net/blog/wp-content/uploads/2009/06/console-functions-memer-resolve1-thumb1.png" border="0" alt="console_functions_memer_resolve1" width="337" height="185" /></a></p>
<h3><span style="text-decoration: underline;">Getting more out of Functions</span></h3>
<p>So far the approach is a little static from a functional point of view so perhaps we could do this a little differently? If we define the following functions we get some equivalent behaviour to our utility class.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">Func&lt;Expression&lt;Func&lt;Criteria, <span style="color: #0000ff;">int</span>&gt;&gt;, Expression&gt; criteriaFunction =
    c =&gt; c.Body;

Func&lt;Expression, <span style="color: #0000ff;">string</span>&gt; propertyResolverFunction = e =&gt;
{
    <span style="color: #0000ff;">if</span> (ExpressionType.MemberAccess == e.NodeType)
    {
        var memberExpr = (MemberExpression)e;
        <span style="color: #0000ff;">return</span> memberExpr.Member.Name;
    }
    <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (ExpressionType.Call == e.NodeType)
    {
        var methodExpr = (MethodCallExpression)e;
        <span style="color: #0000ff;">return</span> methodExpr.Method.Name;
    }
    <span style="color: #0000ff;">else</span>
    {
        <span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> NotImplementedException(
            <span style="color: #0000ff;">string</span>.Format(<span style="color: #006080;">&#8220;Resolving names from expression types &#8220;</span> +
            <span style="color: #006080;">&#8220;of {0} is not implemented!&#8221;</span>,
            e.Type.Name));
    }
};

var propertyName =
    propertyResolverFunction(
        criteriaFunction(c =&gt; c.PageCounter));

Console.WriteLine(propertyName);</pre>
</div>
<p>Here we have created two functions that can be used together to achieve our required end result. The first function <strong><em>criteriaFunction</em></strong>, takes a generic expression as an argument and returns an expression. The second function <em><strong>propertyResolverFunction</strong></em>, takes an expression as it’s argument and returns a string. By passing one function as an argument to the other, we achieve the same results as with the static utility class already demonstrated. To collapse this even further we can wrap up both those functions  into one.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">Func&lt;Expression&lt;Func&lt;Criteria, <span style="color: #0000ff;">string</span>&gt;&gt;, Func&lt;Expression, <span style="color: #0000ff;">string</span>&gt;&gt; allInOne =
    c =&gt; e =&gt;
    {

        <span style="color: #0000ff;">if</span> (ExpressionType.MemberAccess == e.NodeType)
        {
            var memberExpr = (MemberExpression)e;
            <span style="color: #0000ff;">return</span> memberExpr.Member.Name;
        }
        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (ExpressionType.Call == e.NodeType)
        {
            var methodExpr = (MethodCallExpression)e;
            <span style="color: #0000ff;">return</span> methodExpr.Method.Name;
        }
        <span style="color: #0000ff;">else</span>
        {
            <span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> NotImplementedException(
                <span style="color: #0000ff;">string</span>.Format(<span style="color: #006080;">&#8220;Resolving names from expression types &#8220;</span> +
            <span style="color: #006080;">&#8220;of {0} is not implemented!&#8221;</span>,
                e.Type.Name));
        }
    };

Expression&lt;Func&lt;Criteria, <span style="color: #0000ff;">string</span>&gt;&gt; exp = c =&gt; c.Levels;
var property_name_allinone = allInOne(exp)(exp.Body);

Console.WriteLine(property_name_allinone);</pre>
</div>
<p>When we call the <strong><em>allinone</em></strong> function with the expression argument, it returns a function that in turns take the body property of the same expression that was passed to the <a href="http://en.wikipedia.org/wiki/Higher-order_function" target="_blank">higher order function</a>. All the code in the post presumes the the following class:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> Criteria
{
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">decimal</span> Percent;

    <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">int</span> _pageCounter;

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">int</span> PageCounter
    {
        get { <span style="color: #0000ff;">return</span> _pageCounter; }
        set { _pageCounter = <span style="color: #0000ff;">value</span>; }
    }

    <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">string</span> _levels;

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> Levels
    {
        get { <span style="color: #0000ff;">return</span> _levels; }
        set { _levels = <span style="color: #0000ff;">value</span>; }
    }

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> SomeMethod() { }

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> SomeMethodWithArgs(<span style="color: #0000ff;">string</span> arg1, <span style="color: #0000ff;">int</span> arg2,
        <span style="color: #0000ff;">params</span> <span style="color: #0000ff;">string</span>[] arg3) { }
}</pre>
</div>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Type%20Member%20Name%20Resolution%20with%20Functions%20%26ndash%3B%20Part%202.0&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F06%2F16%2Ftype-member-name-resolution-with-functions-part-20%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Type Member Name Resolution with Functions &ndash; Part 2.0";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/06/16/type-member-name-resolution-with-functions-part-20/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=fb2lRUwhfNA:XMsFtQynZ3A:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=fb2lRUwhfNA:XMsFtQynZ3A:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=fb2lRUwhfNA:XMsFtQynZ3A:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=fb2lRUwhfNA:XMsFtQynZ3A:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=fb2lRUwhfNA:XMsFtQynZ3A:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=fb2lRUwhfNA:XMsFtQynZ3A:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=fb2lRUwhfNA:XMsFtQynZ3A:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=fb2lRUwhfNA:XMsFtQynZ3A:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=fb2lRUwhfNA:XMsFtQynZ3A:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=fb2lRUwhfNA:XMsFtQynZ3A:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=fb2lRUwhfNA:XMsFtQynZ3A:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/fb2lRUwhfNA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/06/16/type-member-name-resolution-with-functions-part-20/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/06/16/type-member-name-resolution-with-functions-part-20/</feedburner:origLink></item>
		<item>
		<title>Ten+ Year Perspective</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/Zf9bYSm4GIc/</link>
		<comments>http://www.simonsegal.net/blog/2009/06/13/ten-year-perspective/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 05:25:04 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[Career]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/06/13/ten-year-perspective/</guid>
		<description><![CDATA[This blog is normally strictly technical and I will rarely deviate from that self imposed constraint but in a rare deviation here goes with something a bit different.
For anyone who just happened upon this post and perhaps those who know me or have followed this blog may or may not be aware, I was a [...]]]></description>
			<content:encoded><![CDATA[<p>This blog is normally strictly technical and I will rarely deviate from that self imposed constraint but in a rare deviation here goes with something a bit different.</p>
<p>For anyone who just happened upon this post and perhaps those who know me or have followed this blog may or may not be aware, I was a musician in one of my previous careers. I have not abandoned my music completely in the decade or so that I moved into software however let’s just say it took a very big back seat.</p>
<p>Initially drawn to software development as a better paying yet still highly creative profession, I would often tell myself that writing good code was like writing or producing a good song and though the output was different in format and audience expectations, the experience was still fulfilling a side of me that required feeding.</p>
<p>A decade into my software development career and I can now say that whilst it does satisfy a creative urge, it can never come close to the emotional connection and responses that music emote in me. Recent days spent with headphones and my MP3 player have me on the verge of propelling myself into some musical journey and exactly what that is I am not sure right now but I am filled with excitement and overwhelming sense of promise.</p>
<p>My final observation is this: even with a strong resolve to travel some undiscovered musical road, I still feel the ‘coding’ drug flowing through my veins. I am, I code, I live, I die.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Ten%2B%20Year%20Perspective&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F06%2F13%2Ften-year-perspective%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Ten+ Year Perspective";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/06/13/ten-year-perspective/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Zf9bYSm4GIc:_0v5-NWoKjY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Zf9bYSm4GIc:_0v5-NWoKjY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=Zf9bYSm4GIc:_0v5-NWoKjY:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Zf9bYSm4GIc:_0v5-NWoKjY:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Zf9bYSm4GIc:_0v5-NWoKjY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=Zf9bYSm4GIc:_0v5-NWoKjY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Zf9bYSm4GIc:_0v5-NWoKjY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Zf9bYSm4GIc:_0v5-NWoKjY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=Zf9bYSm4GIc:_0v5-NWoKjY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Zf9bYSm4GIc:_0v5-NWoKjY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=Zf9bYSm4GIc:_0v5-NWoKjY:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/Zf9bYSm4GIc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/06/13/ten-year-perspective/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/06/13/ten-year-perspective/</feedburner:origLink></item>
		<item>
		<title>Functional Type member resolution with C#</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/MLcosln8D4I/</link>
		<comments>http://www.simonsegal.net/blog/2009/06/11/functional-type-member-resolution-with-c/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 14:06:48 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/06/11/functional-type-member-resolution-with-c/</guid>
		<description><![CDATA[An interesting problem cropped up today regarding reflection and how LINQ might make for a strongly typed solution. K. Scott Allen suggested a while back to use lambdas to remove the use of ‘magic’ strings in building Fetching Intentions used in NFetchSpec and it was suggested by my colleague Mark that a similar approach be [...]]]></description>
			<content:encoded><![CDATA[<p>An interesting problem cropped up today regarding reflection and how LINQ might make for a strongly typed solution. <a href="http://odetocode.com/Blogs/scott/default.aspx" target="_blank">K. Scott Allen</a> <a href="http://www.simonsegal.net/blog/2009/02/11/the-entity-framework-and-a-unified-lazy-and-eager-loading-framework/#comments" target="_blank">suggested</a> a while back to use lambdas to remove the use of ‘magic’ strings in building <a href="http://www.simonsegal.net/blog/2009/02/23/entity-framework-repositories-specifications-and-fetching-strategies-part-90/" target="_blank">Fetching Intentions used in NFetchSpec</a> and it was suggested by my colleague Mark that a similar approach be used in resolving a types property name using strongly typed expressions. Given the following class:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> Criteria
{
    <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">int</span> _pageCounter;

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">int</span> PageCounter
    {
        get { <span style="color: #0000ff;">return</span> _pageCounter; }
        set { _pageCounter = <span style="color: #0000ff;">value</span>; }
    }

    <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">string</span> _levels;

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> Levels
    {
        get { <span style="color: #0000ff;">return</span> _levels; }
        set { _levels = <span style="color: #0000ff;">value</span>; }
    }
}</pre>
</div>
<p>I want to dynamically resolve any property name using an Expression such as:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">Expression&lt;Func&lt;Criteria, <span style="color: #0000ff;">string</span>&gt;&gt; f = c =&gt; c.Levels;</pre>
</div>
<p>After fumbling around for a while it occurred that functional programming was yet again the simplest way to approach this.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> PropertyNameResolver&lt;T&gt;
{
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> Resolve&lt;TPropertyType&gt;
        (Expression&lt;Func&lt;T, TPropertyType&gt;&gt; expression)
    {
        Func&lt;Expression&lt;Func&lt;T, TPropertyType&gt;&gt;, <span style="color: #0000ff;">string</span>&gt;
            prop_name_function = l =&gt;
            {
                <span style="color: #0000ff;">int</span> posDot = l.Body.ToString().LastIndexOf(<span style="color: #006080;">&#8220;.&#8221;</span>) + 1;
                <span style="color: #0000ff;">return</span> l.Body.ToString().Remove(0, posDot);
            };
        var property_name =
            <span style="color: #0000ff;">typeof</span>(T).GetProperty(prop_name_function(expression)).Name;
        <span style="color: #0000ff;">return</span> property_name;
    }
}</pre>
</div>
<p>By supplying the expression and encapsulating the function that takes the expression as an argument, we get access to the body and parameters in the expression tree built by the original lambda and when be execute the outer function we can extrapolate the property name. Here’s an example of the usage:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var pc = PropertyNameResolver&lt;Criteria&gt;.Resolve&lt;<span style="color: #0000ff;">int</span>&gt;(c =&gt; c.PageCounter);
Console.WriteLine(pc);</pre>
</div>
<p>Functional goodness in C#.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Functional%20Type%20member%20resolution%20with%20C%23&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F06%2F11%2Ffunctional-type-member-resolution-with-c%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Functional Type member resolution with C#";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/06/11/functional-type-member-resolution-with-c/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=MLcosln8D4I:bxcmGpm05kw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=MLcosln8D4I:bxcmGpm05kw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=MLcosln8D4I:bxcmGpm05kw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=MLcosln8D4I:bxcmGpm05kw:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=MLcosln8D4I:bxcmGpm05kw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=MLcosln8D4I:bxcmGpm05kw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=MLcosln8D4I:bxcmGpm05kw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=MLcosln8D4I:bxcmGpm05kw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=MLcosln8D4I:bxcmGpm05kw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=MLcosln8D4I:bxcmGpm05kw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=MLcosln8D4I:bxcmGpm05kw:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/MLcosln8D4I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/06/11/functional-type-member-resolution-with-c/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/06/11/functional-type-member-resolution-with-c/</feedburner:origLink></item>
		<item>
		<title>Using Ruby Naming Conventions in C# code? Is that madness?</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/mhGQOEuUN74/</link>
		<comments>http://www.simonsegal.net/blog/2009/06/09/using-ruby-naming-conventions-in-c-code-is-that-madness/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 10:47:31 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[IronRuby]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/06/09/using-ruby-naming-conventions-in-c-code-is-that-madness/</guid>
		<description><![CDATA[During my journey in learning Ruby / IronRuby, I have caught myself often naming things in C# with a Ruby convention or BDD test naming regime. To be extreme here’s an example:

var customer_to_make_preferred = Get_Customer_By_Id&#60;ICustomerMakePrefered&#62;();

//OR METHODS LIKE THIS

public void Group_By_Orders_And_Print_To_Console_Window()
{
    //&#8230;..etc
}

I really find a benefit in greater understanding when reading code when [...]]]></description>
			<content:encoded><![CDATA[<p>During my journey in learning Ruby / IronRuby, I have caught myself often naming things in C# with a Ruby convention or BDD test naming regime. To be extreme here’s an example:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var customer_to_make_preferred = Get_Customer_By_Id&lt;ICustomerMakePrefered&gt;();

<span style="color: #008000;">//OR METHODS LIKE THIS</span>

<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> Group_By_Orders_And_Print_To_Console_Window()
{
    <span style="color: #008000;">//&#8230;..etc</span>
}</pre>
</div>
<p>I really find a benefit in greater understanding when reading code when I take this approach. Now it’s true I have been programming in C# for some 10 years and I don’t know if this kind of behaviour will see me excommunicated from the circle of brethren or not but I would like to know what others think.</p>
<p>Opinions please! And yes I know this is gonna be like waving a red flag in front of a raging bull :). And for the Ruby people, I am only proposing the extended underscored naming convention and nothing else – it’s all about naming and that’s it – ya basta!</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Using%20Ruby%20Naming%20Conventions%20in%20C%23%20code%3F%20Is%20that%20madness%3F&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F06%2F09%2Fusing-ruby-naming-conventions-in-c-code-is-that-madness%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Using Ruby Naming Conventions in C# code? Is that madness?";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/06/09/using-ruby-naming-conventions-in-c-code-is-that-madness/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=mhGQOEuUN74:Ps3j1rg_UYM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=mhGQOEuUN74:Ps3j1rg_UYM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=mhGQOEuUN74:Ps3j1rg_UYM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=mhGQOEuUN74:Ps3j1rg_UYM:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=mhGQOEuUN74:Ps3j1rg_UYM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=mhGQOEuUN74:Ps3j1rg_UYM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=mhGQOEuUN74:Ps3j1rg_UYM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=mhGQOEuUN74:Ps3j1rg_UYM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=mhGQOEuUN74:Ps3j1rg_UYM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=mhGQOEuUN74:Ps3j1rg_UYM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=mhGQOEuUN74:Ps3j1rg_UYM:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/mhGQOEuUN74" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/06/09/using-ruby-naming-conventions-in-c-code-is-that-madness/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/06/09/using-ruby-naming-conventions-in-c-code-is-that-madness/</feedburner:origLink></item>
		<item>
		<title>Entity Framework Repository and Fetching Strategies code update!</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/P5hE3SGJGKY/</link>
		<comments>http://www.simonsegal.net/blog/2009/06/05/entity-framework-repository-and-fetching-strategies-code-update/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 09:56:39 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/06/05/entity-framework-repository-and-fetching-strategies-code-update/</guid>
		<description><![CDATA[It recently came to my attention that the code for this series of posts got entangled in a brain freeze mix up when I uploaded some zip files recently. Therefore the code is now located in the subversion repository.
Part 1
Part 2
Part 3
Part 4
Part 5
Part 6
Part 7
Part 8
Part 9
Part 10
Part 11
The Code is here.

   [...]]]></description>
			<content:encoded><![CDATA[<p>It recently came to my attention that the code for this series of posts got entangled in a <span style="text-decoration: line-through;">brain freeze</span> mix up when I uploaded some zip files recently. Therefore the code is now located in the subversion repository.</p>
<p><a href="../blog/2008/12/15/more-entity-framework-frustration-i-want-my-specification-pattern/">Part 1</a><br />
<a href="../blog/2008/12/17/narrowing-orm-options-for-the-sake-of-sanity/">Part 2</a><br />
<a href="../blog/2008/12/22/entity-framework-and-the-specification-pattern/">Part 3</a><br />
<a href="../blog/2008/12/23/entity-framework-specification-pattern-code-update/">Part 4</a><br />
<a href="../blog/2009/01/07/fetching-strategies-for-the-entity-framework-a-waste-of-time-for-now/">Part 5</a><br />
<a href="../blog/2009/01/13/entity-framework-repository-specifications-and-fetching-strategies/">Part 6</a><br />
<a href="../blog/2009/02/11/the-entity-framework-and-a-unified-lazy-and-eager-loading-framework/">Part 7</a><br />
<a href="../2009/02/22/entity-framework-repositories-specifications-and-fetching-strategies-part-80/">Part 8</a><br />
<a href="../blog/2009/02/23/entity-framework-repositories-specifications-and-fetching-strategies-part-90/">Part 9</a><br />
<a href="../blog/2009/02/24/entity-framework-repositories-specifications-and-fetching-strategies-part-100-or-lazy-loading-and-fetching-strategies-again-with-feeling/">Part 10</a><br />
<a href="../blog/2009/03/05/lazy-loading-and-the-entity-framework-how-long-i-can-go-on-like-this/">Part 11</a></p>
<p><a href="http://simonsegal.net/TechAPublicRepo/Trunk/EntityFramework-Repo-Fetching-Strategies/Org.Techavalanche.Orm.Entities" target="_blank">The Code is here.</a></p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Entity%20Framework%20Repository%20and%20Fetching%20Strategies%20code%20update%21&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F06%2F05%2Fentity-framework-repository-and-fetching-strategies-code-update%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Entity Framework Repository and Fetching Strategies code update!";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/06/05/entity-framework-repository-and-fetching-strategies-code-update/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=P5hE3SGJGKY:tgMv8_Wia8Q:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=P5hE3SGJGKY:tgMv8_Wia8Q:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=P5hE3SGJGKY:tgMv8_Wia8Q:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=P5hE3SGJGKY:tgMv8_Wia8Q:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=P5hE3SGJGKY:tgMv8_Wia8Q:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=P5hE3SGJGKY:tgMv8_Wia8Q:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=P5hE3SGJGKY:tgMv8_Wia8Q:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=P5hE3SGJGKY:tgMv8_Wia8Q:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=P5hE3SGJGKY:tgMv8_Wia8Q:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=P5hE3SGJGKY:tgMv8_Wia8Q:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=P5hE3SGJGKY:tgMv8_Wia8Q:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/P5hE3SGJGKY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/06/05/entity-framework-repository-and-fetching-strategies-code-update/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/06/05/entity-framework-repository-and-fetching-strategies-code-update/</feedburner:origLink></item>
		<item>
		<title>Don’t be COMMON, in Oslo MGrammar or any language for that matter.</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/NfVFWUjTAtE/</link>
		<comments>http://www.simonsegal.net/blog/2009/06/02/dont-be-common-oh-and-by-the-way-oslo-mgrammar-is-no-exception/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 10:59:26 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[MGrammar]]></category>

		<category><![CDATA[Oslo]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/06/02/dont-be-common-oh-and-by-the-way-oslo-mgrammar-is-no-exception/</guid>
		<description><![CDATA[I have yet to be convinced (some have tried) that any code libraries warranted the COMMON label. When tested by colleagues on this, it turned out that  the contents of any so-called COMMON libraries could easily broken into several new libraries or had their contents attributed to existing libraries within the domain and none of [...]]]></description>
			<content:encoded><![CDATA[<p>I have yet to be convinced (some have tried) that any code libraries warranted the COMMON label. When tested by colleagues on this, it turned out that  the contents of any so-called COMMON libraries could easily broken into several new libraries or had their contents attributed to existing libraries within the domain and none of them labelled as COMMON.</p>
<p>This really is one of my pet hates and I keep seeing it over and over again and recently came across it again whilst reading the Microsoft primer document on <a title="MGrammar Primer PDF Link" href="http://download.microsoft.com/download/D/A/B/DAB9E2D8-3A27-4BA7-BE66-8600EE4E33B0/MGrammar_Language_Specification.pdf" target="_blank">MGrammer</a>. At the time of this writing the link provided here is not available, presumably due to the timing of the latest CTP drop of the Oslo tools (which now includes Quadrant) but I digress.</p>
<p>This is just the latest offence of the <strong>COMMON </strong>misdemeanour that I have come across.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">module SongSample
{
    language Common
    {
        <span style="color: #008000;">// Parameterized List rule</span>
        syntax List(element)
            = e:element =&gt; [e]
            | es:List(element) e:element =&gt; [valuesof(es), e];
        <span style="color: #008000;">// Whitespace</span>
        syntax LF = <span style="color: #006080;">&#8220;\u000A&#8221;</span>;
        syntax CR = <span style="color: #006080;">&#8220;\u000D&#8221;</span>;
        syntax Space = <span style="color: #006080;">&#8220;\u0020&#8243;</span>;
        syntax Whitespace = LF | CR | Space;
    }
    language Song
    {
        <span style="color: #008000;">// Reference List rule in Common language</span>
        syntax Bars = bs:Common.List(Bar) =&gt; Bars[valuesof(bs)];
        syntax Songs = ss:Common.List(ASong) =&gt; Songs[valuesof(ss)];
        <span style="color: #008000;">// Reference Whitespace rule in Common language</span>
        interleave Whitespace = Common.Whitespace;
    }
    language AnotherLanguage
    {
        <span style="color: #008000;">// Reference List rule in Common language</span>
        syntax ListOfAs = Common.List(<span style="color: #006080;">&#8220;A&#8221;</span>);
    }
}</pre>
</div>
<p>Here we can see that in an effort to describe reusable rules across languages, a language call COMMON has been created with the idea the the syntax rule definitions might be reused, therefore becoming <strong><em>‘common’</em></strong> amongst the other languages that reuse them. The thing that starts me wanting to chew on my ear is the use of the word COMMON, which is a word that is descriptive of <strong><em><span style="text-decoration: underline;">nothing</span></em></strong>! COMMON tells me nothing by looking at it. COMMON ensures that I must read the contents if I want to begin to gain an understanding. If we consider that the ‘so-called’ common language (above) contains a parameterized list rule and a set of syntax rules for whitespace, space and line termination then perhaps we can craft some description around those elements? Perhaps we might take the LF, CR, Space and Whitespace elements and put them in a language called MusicalWhitespace? Now I’m sure plenty of you can come up with a better name than that, but I guess the point is that <em><strong>MusicalWhitespace</strong></em> gives me some idea of what it might be about. I still prefer not to let my intent get lost by being common.</p>
<p>Let me finish by saying that I know that the author of the MGrammar in a nutshell document was using this to convey the reuse in as simple and obvious fashion possible and I am not taking a swipe at that document, on the contrary it’s a great quick start into MGrammer, it simply offered an example (albeit a non real world one) where the concept was present and could be highlighted.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Don%26rsquo%3Bt%20be%20COMMON%2C%20in%20Oslo%20MGrammar%20or%20any%20language%20for%20that%20matter.&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F06%2F02%2Fdont-be-common-oh-and-by-the-way-oslo-mgrammar-is-no-exception%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Don&rsquo;t be COMMON, in Oslo MGrammar or any language for that matter.";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/06/02/dont-be-common-oh-and-by-the-way-oslo-mgrammar-is-no-exception/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=NfVFWUjTAtE:SBUdwqWyEWo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=NfVFWUjTAtE:SBUdwqWyEWo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=NfVFWUjTAtE:SBUdwqWyEWo:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=NfVFWUjTAtE:SBUdwqWyEWo:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=NfVFWUjTAtE:SBUdwqWyEWo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=NfVFWUjTAtE:SBUdwqWyEWo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=NfVFWUjTAtE:SBUdwqWyEWo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=NfVFWUjTAtE:SBUdwqWyEWo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=NfVFWUjTAtE:SBUdwqWyEWo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=NfVFWUjTAtE:SBUdwqWyEWo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=NfVFWUjTAtE:SBUdwqWyEWo:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/NfVFWUjTAtE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/06/02/dont-be-common-oh-and-by-the-way-oslo-mgrammar-is-no-exception/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/06/02/dont-be-common-oh-and-by-the-way-oslo-mgrammar-is-no-exception/</feedburner:origLink></item>
		<item>
		<title>A WPF - IronRuby Scripting Console User Control</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/zYCDumxutUk/</link>
		<comments>http://www.simonsegal.net/blog/2009/05/30/a-wpf-ironruby-scripting-console-user-control/#comments</comments>
		<pubDate>Sat, 30 May 2009 07:40:45 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[DLR]]></category>

		<category><![CDATA[IronRuby]]></category>

		<category><![CDATA[WPF]]></category>

		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/05/30/a-wpf-ironruby-scripting-console-user-control/</guid>
		<description><![CDATA[One of the clear value added possibilities with IronRuby and IronPython (or any DLR language) has to offer is making applications scriptable. This opens the possibility for enabling scripting of your application, it’s types and potentially objects running in memory in your application at runtime. I recently went looking for an IronRuby console / shell [...]]]></description>
			<content:encoded><![CDATA[<p>One of the clear value added possibilities with IronRuby and IronPython (or any DLR language) has to offer is making applications scriptable. This opens the possibility for enabling scripting of your application, it’s types and potentially objects running in memory in your application at runtime. I recently went looking for an IronRuby console / shell window control written natively in WPF and turned up nothing. I did however come across some examples implemented for Windows Forms and the one that got my attention was <a href="http://blog.orionedwards.com/2008/09/embedded-ironruby-interactive-console.html" target="_blank">Orion Edwards</a> Embedded IronRuby Interactive Console.</p>
<p>Whilst Orion’s project provided the basis of what I was after, I was under no illusion that I would find exactly what I was after and would therefore have to build out the rest of the functionality I required.</p>
<h3><span style="text-decoration: underline;">The Basic Requirements List</span></h3>
<ul>
<li>Reusable WPF User Control</li>
<li>The Console should allow users to write script against in memory objects of the host application.</li>
<li>Should persist (to a log) the state of variables in the IronRuby runtime scopes.</li>
<li>Extensible Application Design and easily maintained and Testable.</li>
</ul>
<p>So rather than re-invent the wheel I started out with Orion’s code and worked it into a WPF User Control that followed the MVP pattern. This version supports printing of all scope variable state to the console window, clearing of the console window text and all the out of the box access to the IronRuby runtime from the console itself. The IronRuby Console User control also allows the consumer application to pass through in memory variables from your managed CLR hosting application.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2009/05/ir-console-for-wpf.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ir_console_for_wpf" src="http://www.simonsegal.net/blog/wp-content/uploads/2009/05/ir-console-for-wpf-thumb.png" border="0" alt="ir_console_for_wpf" width="479" height="452" /></a></p>
<p>Finally I need to also make mention that some of the classes used to stream the STD/IO came directly from <a href="http://blog.benhall.me.uk/" target="_blank">Ben Halls</a> wonderful <a href="http://www.codeplex.com/IronEditor" target="_blank">IronEditor</a>. And before I forget, the code can found <a title="Subersion Repository for IronRuby Console" href="http://simonsegal.net/TechAPublicRepo/Trunk/WpfIronRubyConsole" target="_blank">here</a> on my blogs subversion repository.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=A%20WPF%20-%20IronRuby%20Scripting%20Console%20User%20Control&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F05%2F30%2Fa-wpf-ironruby-scripting-console-user-control%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="A WPF - IronRuby Scripting Console User Control";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/05/30/a-wpf-ironruby-scripting-console-user-control/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=zYCDumxutUk:gCRVMk4m8cQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=zYCDumxutUk:gCRVMk4m8cQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=zYCDumxutUk:gCRVMk4m8cQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=zYCDumxutUk:gCRVMk4m8cQ:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=zYCDumxutUk:gCRVMk4m8cQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=zYCDumxutUk:gCRVMk4m8cQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=zYCDumxutUk:gCRVMk4m8cQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=zYCDumxutUk:gCRVMk4m8cQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=zYCDumxutUk:gCRVMk4m8cQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=zYCDumxutUk:gCRVMk4m8cQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=zYCDumxutUk:gCRVMk4m8cQ:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/zYCDumxutUk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/05/30/a-wpf-ironruby-scripting-console-user-control/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/05/30/a-wpf-ironruby-scripting-console-user-control/</feedburner:origLink></item>
		<item>
		<title>High functioning autistics don’t work in vacuums</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/Vk3kzF-e54w/</link>
		<comments>http://www.simonsegal.net/blog/2009/05/29/high-functioning-autistics-dont-work-in-vacuums/#comments</comments>
		<pubDate>Fri, 29 May 2009 13:13:53 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[BDD]]></category>

		<category><![CDATA[Communication]]></category>

		<category><![CDATA[developers]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/05/29/high-functioning-autistics-dont-work-in-vacuums/</guid>
		<description><![CDATA[I had the pleasure of recently listening to one of the most entertaining podcasts I have heard in a while where Scott Bellware was the guest in question. Scott is a captivating speaker and always prompts you to challenge your own beliefs and ideas as a developer. The podcast was intended to be centred around [...]]]></description>
			<content:encoded><![CDATA[<p>I had the pleasure of recently listening to one of the <a href="http://herdingcode.com/?p=176" target="_blank">most entertaining podcasts</a> I have heard in a while where Scott Bellware was the guest in question. Scott is a captivating speaker and always prompts you to challenge your own beliefs and ideas as a developer. The podcast was intended to be centred around a discussion on BDD however Scott points out that he practices “Context Specification” and that it differs somewhat to BDD.</p>
<p>Something that has stayed with me in the weeks passed since listening the to discussion, is Scott’s description of developers as ‘<strong><em>high functioning autistics’</em></strong>. The context in which Scott makes the observation is one where he expresses a desire for developers to speak more fluently in the language of the business and desist in articulating implementation details or information of no business value. I’m sure that most people will find that idea logical and reasonable (as I do) however I feel that it’s worth throwing some attention onto the business and how it communicates in the reverse direction.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2009/05/the-team.png" target="_blank"><img style="border-right-width: 0px; margin: 0px 5px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="the_team" src="http://www.simonsegal.net/blog/wp-content/uploads/2009/05/the-team-thumb.png" border="0" alt="the_team" width="260" height="205" align="left" /></a> Any relationships success relies on the mutual respect and determination of all parties to participate in functioning cohesively to achieve a common goal. Yes developers should aim to achieve communicating more effectively with the business but it should be said that business people must take an equal position of responsibility for the success of communication between the parties. I’m pretty sure that most developers have worked in environments with little structure or discipline, where ad-hoc is the methodology of the day and expectations are generally unreasonable. I am sorry to say that I have seen developers purposefully communicate in an abstract way with business people, in an attempt to shield themselves from the kind of environment I just described.</p>
<p>I find it curious that we even speak of ‘developers’ and the ‘business’ as separate entities almost as though they exist in different dimensions; surely we developers work for the very same business as do those in HR, Sales or Warehousing? By definition we must also be considered <strong><em>part</em></strong> of the business. Seriously though, I understand the distinction when we speak about ‘software’ and the ‘business’ in terms that express a notion of separation, but I guess I am starting to think that it’s a consequence of the inadequacy of language that helps in promoting exactly some of the problems that Scott wants to see eradicated.</p>
<p>I think it’s worth making the observation that whilst developers should take responsibility for themselves in communicating more effectively across the organisation they serve, it’s incumbent on all parties to create environments designed for successful communication that travels in all directions. There have been plenty of occasions where I have seen ‘business people’ behave in a fashion that demonstrated a lack of respect and understanding of those sitting on the IT side of the fence. Respect is a two way street.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=High%20functioning%20autistics%20don%26rsquo%3Bt%20work%20in%20vacuums&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F05%2F29%2Fhigh-functioning-autistics-dont-work-in-vacuums%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="High functioning autistics don&rsquo;t work in vacuums";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/05/29/high-functioning-autistics-dont-work-in-vacuums/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Vk3kzF-e54w:hOCC-ivHtKk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Vk3kzF-e54w:hOCC-ivHtKk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=Vk3kzF-e54w:hOCC-ivHtKk:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Vk3kzF-e54w:hOCC-ivHtKk:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Vk3kzF-e54w:hOCC-ivHtKk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=Vk3kzF-e54w:hOCC-ivHtKk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Vk3kzF-e54w:hOCC-ivHtKk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Vk3kzF-e54w:hOCC-ivHtKk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=Vk3kzF-e54w:hOCC-ivHtKk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Vk3kzF-e54w:hOCC-ivHtKk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=Vk3kzF-e54w:hOCC-ivHtKk:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/Vk3kzF-e54w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/05/29/high-functioning-autistics-dont-work-in-vacuums/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/05/29/high-functioning-autistics-dont-work-in-vacuums/</feedburner:origLink></item>
		<item>
		<title>Entity Framework, Fluent Interfaces &amp; Domain Specific Languages</title>
		<link>http://feedproxy.google.com/~r/simonsegal/rQlV/~3/Qh4d5xCWB1Y/</link>
		<comments>http://www.simonsegal.net/blog/2009/05/24/entity-framework-fluent-interfaces-domain-specific-languages/#comments</comments>
		<pubDate>Sat, 23 May 2009 14:12:36 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[DSL]]></category>

		<category><![CDATA[Entity Framework]]></category>

		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2009/05/24/entity-framework-fluent-interfaces-domain-specific-languages/</guid>
		<description><![CDATA[I have been giving some thought lately  to how we might go about writing a small internal DSL for reporting on and or editing data in database. Immediately I thought about how LINQ (a DSL in its own right) might play it’s part in this and since we are talking Data, then the Entity Framework [...]]]></description>
			<content:encoded><![CDATA[<p>I have been giving some thought lately  to how we might go about writing a small internal DSL for reporting on and or editing data in database. Immediately I thought about how LINQ (a DSL in its own right) might play it’s part in this and since we are talking Data, then the Entity Framework came immediately into consideration. Why should we have a DSL for accessing Data? It’s a commonly held opinion that SQL is a DSL for that very purpose, albeit a very general purpose DSL and LINQ is certainly a DSL.</p>
<p>Let’s consider the workers of the Northwind Trading company as an example of some possible beneficiaries to such a Data Centric DSL modelled around a specific business. Of course workers at Northwind have MS Access and SQL Server GUI tools (often called Graphical DSL’s), to help design their queries.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2009/05/query-designer.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="query_designer" src="http://www.simonsegal.net/blog/wp-content/uploads/2009/05/query-designer-thumb.png" border="0" alt="query_designer" width="480" height="448" /></a></p>
<h3><span style="text-decoration: underline;">A snippet</span></h3>
<p>So what would our Northwind language look like? Given that we set up from the start to consider an internal DSL, I have chosen to use C# to implement this “little language” (very little) and we will use a fluent interface to accommodate our design. A query might be expressed like this:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> Do()
{
    <span style="color: #0000ff;">var</span> custs = <span style="color: #006080;">NorthwindLang</span>
        .Customers
        .WithOrdersShippedFrom(<span style="color: red;">&#8220;Germany&#8221;</span>)
        .That()
        .Are()
        .OlderInYearsBy(5);
}</pre>
</div>
<h3></h3>
<h3><span style="text-decoration: underline;">The Language</span></h3>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">class</span> NorthwindLang
{
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Customer[] Customers;
    <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> NorthwindEntities ctx = <span style="color: #0000ff;">null</span>;

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Customer[] WithOrdersShippedFrom(<span style="color: #0000ff;">this</span> Customer[] customers,
        <span style="color: #0000ff;">string</span> country)
    {
        ctx = <span style="color: #0000ff;">new</span> NorthwindEntities();
        var customers_and_orders =
           (ObjectQuery&lt;Customer&gt;)
           from c <span style="color: #0000ff;">in</span> ctx.Customers.Include(<span style="color: #006080;">&#8220;Orders&#8221;</span>)
           <span style="color: #0000ff;">where</span> c.Orders.Any(o =&gt; o.ShipCountry == country)
           select c;

        Console.WriteLine(customers_and_orders.ToTraceString());

        customers = customers_and_orders.ToArray();

        customers.ToList()
            .ForEach(c =&gt; c.Orders.ToList()
                .ForEach(o =&gt; {
                    <span style="color: #0000ff;">if</span> (o.ShipCountry != country)
                    {
                        ctx.Detach(o);
                    }}));

        <span style="color: #0000ff;">return</span> customers;
    }

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Customer[] That(<span style="color: #0000ff;">this</span> Customer[] customers)
    {
        <span style="color: #0000ff;">return</span> customers;
    }

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Customer[] Are(<span style="color: #0000ff;">this</span> Customer[] customers)
    {
        <span style="color: #0000ff;">return</span> customers;
    }

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Customer[] OlderInYearsBy(<span style="color: #0000ff;">this</span> Customer[] customers, <span style="color: #0000ff;">int</span> years)
    {
        var years_ago = DateTime.Now.AddYears(-years);

        var newOrds = <span style="color: #0000ff;">new</span> EntityCollection&lt;Order&gt;();

        var coolFunc =
            <span style="color: #0000ff;">new</span> Func&lt;IEnumerable&lt;Order&gt;,
                EntityCollection&lt;Order&gt;&gt;(o =&gt;
            {
                newOrds = <span style="color: #0000ff;">new</span> EntityCollection&lt;Order&gt;();
                o.ToList().
                    ForEach(ord =&gt; { ctx.Detach(ord);
                        newOrds.Add(ord); });
                <span style="color: #0000ff;">return</span> newOrds;
            });

        var filtered_customers =
            from c <span style="color: #0000ff;">in</span> customers
                 let neworders =
                      (from o <span style="color: #0000ff;">in</span> c.Orders
                      <span style="color: #0000ff;">where</span> (o.ShippedDate.HasValue) &amp;&amp;
                            (o.ShippedDate.Value &lt; years_ago)
                      select o)
                 select <span style="color: #0000ff;">new</span> Customer()
                 {
                     CustomerID = c.CustomerID,
                     CompanyName = c.CompanyName,
                     Orders = coolFunc(neworders)
                 };

        customers =
            filtered_customers
            .Distinct()
            .ToArray();

        <span style="color: #0000ff;">return</span> customers;
    }
}</pre>
</div>
<div></div>
<h3><span style="text-decoration: underline;">Problematic</span></h3>
<p>Something worth noting about the <em><strong>OlderInYearsBy</strong></em>() method is the projection taking place with the Orders property assignment for each new Customer entity projected in the queries select clause. You can see that we are “projecting” the orders that match the criteria into the customers Orders collection, however as they have already been fetched from the Database and are attached to an ObjectContext, we need to detach them so they can be referenced by a new Customer Entity that is being returned in the array of Customers produced by the function. Also, you may have observed that we are working with extensions to Customer arrays and not EntityCollection&lt;T&gt; where T is of type <strong><em>Customer</em></strong>, further to that, the code presented is filtering data selected from method calls higher up the call chain of the fluent interface and their is nothing stopping a user from composing a query that does not work with the assumptions present in the fluent interfaces design, and consequently the behaviour may not be as expected. Another issue with this approach is grammar and creating sentences that make little sense and don’t adhere to the DSL’s intended use or rules.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> Do3()
{
    <span style="color: #0000ff;">var</span> custs = <span style="color: #006080;">NorthwindLang</span>
        .That()
        .OlderInYearsBy(15)
        .WithOrdersShippedFrom(<span style="color: red;">&#8220;Italy&#8221;</span>)
        .Are()
        .That()
        .OlderInYearsBy(15);
}</pre>
</div>
<h3><span style="text-decoration: underline;">Where to from here?</span></h3>
<p>I want to follow up with a post on how to achieve similar outcomes using a functional approach and building compound queries using lambda expression that have been joined together with the logical &amp; and | operators. A perfect candidate for this requirement is (dare I say it) the specification pattern. What I hope to achieve with this more functional approach is to be able to compose sentences of intent that build our query so that it can be submitted as one single SQL query. The issue of grammar still remains a problem and I have considered previously that a graphical designer that sits in front of a fluent interface might offer a solution and offer some options with respect to constraining the use of the fluent interface. Consider a UI design surface built with the <a href="http://msdn.microsoft.com/en-us/vsx/default.aspx" target="_blank">VSX DSL tools</a> that sits on top of our NorthwindLang fluent interface. Anyway we shall see where this journey takes us!</p>
<h3><span style="text-decoration: underline;">One final thing</span></h3>
<p>I don’t recommend using an ORM for reporting purposes. The scenario under which this idea was proposed (rather envisioned) was one where the database in question is a constantly renewed small set of data that is exported from an enterprise Document Management System and it’s purpose is to provide an offline view of partitioned data relevant to a consultants work for a given client. This precludes the requirements from having to deal with issues such as concurrency, given that each instance of this database is usually single user in the most literal sense.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Entity%20Framework%2C%20Fluent%20Interfaces%20%26%20Domain%20Specific%20Languages&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2009%2F05%2F24%2Fentity-framework-fluent-interfaces-domain-specific-languages%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Entity Framework, Fluent Interfaces & Domain Specific Languages";
		a2a_linkurl="http://www.simonsegal.net/blog/2009/05/24/entity-framework-fluent-interfaces-domain-specific-languages/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Qh4d5xCWB1Y:5A5XH10AsHc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Qh4d5xCWB1Y:5A5XH10AsHc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=Qh4d5xCWB1Y:5A5XH10AsHc:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Qh4d5xCWB1Y:5A5XH10AsHc:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Qh4d5xCWB1Y:5A5XH10AsHc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=Qh4d5xCWB1Y:5A5XH10AsHc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Qh4d5xCWB1Y:5A5XH10AsHc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Qh4d5xCWB1Y:5A5XH10AsHc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=Qh4d5xCWB1Y:5A5XH10AsHc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/simonsegal/rQlV?a=Qh4d5xCWB1Y:5A5XH10AsHc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/simonsegal/rQlV?i=Qh4d5xCWB1Y:5A5XH10AsHc:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/simonsegal/rQlV/~4/Qh4d5xCWB1Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2009/05/24/entity-framework-fluent-interfaces-domain-specific-languages/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.simonsegal.net/blog/2009/05/24/entity-framework-fluent-interfaces-domain-specific-languages/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 1.072 seconds --><!-- Cached page served by WP-Cache -->
