<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><!-- generator="wordpress/2.3.1" --><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/" version="2.0">

<channel>
	<title>.Net Smoothie</title>
	<link>http://richardbushnell.net</link>
	<description>A perfect blend of all things Dot Net</description>
	<pubDate>Mon, 02 Jun 2008 10:14:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
	<language>en</language>
			<image><link>http://richardbushnell.net</link><url>http://farm1.static.flickr.com/211/509088131_d8563bd805_t.jpg</url><title>Richard Bushnell</title></image><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/dotnetSmoothie" type="application/rss+xml" /><item>
		<title>C# Acrobatics : Lambdas and Expression Methods as a replacement for NVelocity</title>
		<link>http://richardbushnell.net/index.php/2008/06/02/c-acrobatics-lambdas-and-expression-methods-as-a-replacement-for-nvelocity/</link>
		<comments>http://richardbushnell.net/index.php/2008/06/02/c-acrobatics-lambdas-and-expression-methods-as-a-replacement-for-nvelocity/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 10:09:06 +0000</pubDate>
		<dc:creator>Richard Bushnell</dc:creator>
		
		<category><![CDATA[.Net]]></category>

		<category><![CDATA[ASP.Net]]></category>

		<category><![CDATA[C# 3.0]]></category>

		<category><![CDATA[Development]]></category>

		<category><![CDATA[Extension Methods]]></category>

		<category><![CDATA[Lambda Expressions]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[C#]]></category>

		<category><![CDATA[ListView]]></category>

		<category><![CDATA[NVelocity]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/06/02/c-acrobatics-lambdas-and-expression-methods-as-a-replacement-for-nvelocity/</guid>
		<description><![CDATA[I&#8217;ve been very quiet recently. (I&#8217;m trying to not be so loud, Scott.  ) You see, I&#8217;ve been writing a lot of ASP.Net code for a site I&#8217;m working on. And, to be honest, I&#8217;ve been having a lot of trouble. The source code for .Net has been very helpful, and I&#8217;ve learnt a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been very quiet recently. (I&#8217;m trying to not be so <a href="http://www.hanselman.com/blog/ProfessionalismProgrammingAndPunditryAndSuccessAsAMetric.aspx" target="_blank" onclick="javascript:pageTracker._trackVisit('/outbound/article/www.hanselman.com');">loud</a>, Scott. <img src='http://richardbushnell.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ) You see, I&#8217;ve been writing a lot of ASP.Net code for a site I&#8217;m working on. And, to be honest, I&#8217;ve been having a <em>lot</em> of trouble. The <a href="http://richardbushnell.net/index.php/2008/04/18/the-value-of-being-free-to-see-the-source/" target="_blank" >source code for .Net</a> has been very helpful, and I&#8217;ve learnt a lot about what&#8217;s going on under the covers of ASP.Net because of it. </p>
<p>(Note: I won&#8217;t comment here on the quality of the code I&#8217;ve found - I&#8217;ll leave that up to you to judge. But in any case, I&#8217;ve been trying to build on top of it.)</p>
<p>One thing I&#8217;ve found to be important is the reliance on Web Controls. (It&#8217;s got something to do with javascript libraries, but that&#8217;s another story.) Getting away from the &quot;standard&quot; way to do ASP.Net isn&#8217;t easy though. Even the ninjas on the <a href="http://www.haacked.com/archive/2008/05/31/the-design-is-never-right-the-first-time.aspx" target="_blank" onclick="javascript:pageTracker._trackVisit('/outbound/article/www.haacked.com');">ASP.Net MVC</a> team <a href="http://www.haacked.com/archive/2008/05/03/code-based-repeater-for-asp.net-mvc.aspx" target="_blank" onclick="javascript:pageTracker._trackVisit('/outbound/article/www.haacked.com');">seem to be having trouble</a>. However, with the magic of lambdas and extension methods in C#, I think I might have just about managed to get something usable. I thought I&#8217;d publish my work here, and see what comments I got.</p>
<p>I think it&#8217;s best to start with what my ASP.Net code looks like once I&#8217;ve got everything working. (Notice I still have some Web Controls in there, but that&#8217;s because I&#8217;ve not worked out how to do sorting of data without web controls yet.)</p>
<p>The inspiration for this was taken from the <a href="r" target="_blank">improvements made to NVelocity</a> by the gurus on the Castle Project. I thought it looked great, and I&#8217;d like something similar, but I didn&#8217;t really want to learn a whole new scripting language and integrate it into my working environment just for rendering a bit of HTML. So I built some C# classes to do a similar thing for me instead. It&#8217;s not as nice as NVelocity, but it&#8217;s okay for now.</p>
<p><strong>Warning</strong>: The following code may contain statements of a disturbing nature to more sensitive readers. We cannot be held responsible for any confusion, delusion or mental illness caused by this code.</p>
<p>It starts by taking a collection of Task objects, and calling the extension method &quot;ForEach&quot; on them:</p>
<pre class="code"><span style="background: #ffee62">&lt;%</span> Tasks.ForEach(sections =&gt; {
   sections.NoData = tasks =&gt; {
<span style="background: #ffee62">%&gt;
</span><span style="color: blue">   &lt;</span><span style="color: #a31515">p</span><span style="color: blue">&gt;
</span>   Hey, you&#8217;ve got nothing to do.<span style="color: blue">&lt;/</span><span style="color: #a31515">p</span><span style="color: blue">&gt;
   &lt;</span><span style="color: #a31515">p</span><span style="color: blue">&gt;
</span><span style="background: #ffee62">&lt;%
</span>   };
   sections.BeforeAll = tasks =&gt; {
   <span style="background: #ffee62">%&gt;
</span>  <span style="color: blue">&lt;</span><span style="color: #a31515">table </span><span style="color: red">class</span><span style="color: blue">=&quot;task-list&quot;&gt;
    &lt;</span><span style="color: #a31515">tr </span><span style="color: red">class</span><span style="color: blue">=&quot;task-list-header&quot;&gt;
      &lt;</span><span style="color: #a31515">th</span><span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">LinkButton </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">CommandName</span><span style="color: blue">=&quot;Sort&quot; </span><span style="color: red">CommandArgument</span><span style="color: blue">=&quot;StartDate&quot;
          </span><span style="color: red">Text</span><span style="color: blue">=&quot;Started&quot; /&gt;
      &lt;/</span><span style="color: #a31515">th</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">th</span><span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">LinkButton </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">CommandName</span><span style="color: blue">=&quot;Sort&quot; </span><span style="color: red">CommandArgument</span><span style="color: blue">=&quot;DueOn&quot;
          </span><span style="color: red">Text</span><span style="color: blue">=&quot;Due&quot; /&gt;
      &lt;/</span><span style="color: #a31515">th</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">th</span><span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">LinkButton </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">CommandName</span><span style="color: blue">=&quot;Sort&quot; </span><span style="color: red">CommandArgument</span><span style="color: blue">=&quot;Priority&quot;
          </span><span style="color: red">Text</span><span style="color: blue">=&quot;Priority&quot; /&gt;
      &lt;/</span><span style="color: #a31515">th</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">th</span><span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">LinkButton </span><span style="color: red">CssClass</span><span style="color: blue">=&quot;task-description&quot; </span><span style="color: red">CommandName</span><span style="color: blue">=&quot;Sort&quot; </span><span style="color: red">CommandArgument</span><span style="color: blue">=&quot;Title&quot;
          </span><span style="color: red">Text</span><span style="color: blue">=&quot;Description&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; /&gt;
      &lt;/</span><span style="color: #a31515">th</span><span style="color: blue">&gt;</span><span style="color: blue">      &lt;</span><span style="color: #a31515">th</span><span style="color: blue">&gt;
      &lt;/</span><span style="color: #a31515">th</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: #a31515">tr</span><span style="color: blue">&gt;
   </span><span style="background: #ffee62">&lt;%
</span>   };
     sections.Before = task =&gt; {
    <span style="background: #ffee62">%&gt;
</span>    <span style="color: blue">&lt;</span><span style="color: #a31515">tr </span><span style="color: red">class</span><span style="color: blue">=&quot;</span><span style="background: #ffee62">&lt;%</span>= this.tableCssClasses.Next() <span style="background: #ffee62">%&gt;</span><span style="color: blue">&quot;&gt;
    </span><span style="background: #ffee62">&lt;%
</span>   };
   sections.Each = task =&gt; {
    <span style="background: #ffee62">%&gt;</span>
    <span style="color: blue">&lt;</span><span style="color: #a31515">td</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">div </span><span style="color: red">class</span><span style="color: blue">=&#8217;calendar calendar-icon-</span><span style="background: #ffee62">&lt;%</span>= task.StartMonth <span style="background: #ffee62">%&gt;</span><span style="color: blue">&#8216;&gt;
        &lt;</span><span style="color: #a31515">div </span><span style="color: red">class</span><span style="color: blue">=&quot;calendar-day&quot;&gt;
          </span><span style="background: #ffee62">&lt;%</span><span style="color: blue">= </span>task.StartDayOfMonth <span style="background: #ffee62">%&gt;</span><span style="color: blue">&lt;/</span><span style="color: #a31515">div</span><span style="color: blue">&gt;
      &lt;/</span><span style="color: #a31515">div</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: #a31515">td</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">td</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">div </span><span style="color: red">class</span><span style="color: blue">=&#8217;calendar calendar-icon-</span><span style="background: #ffee62">&lt;%</span>= task.DueMonth <span style="background: #ffee62">%&gt;</span><span style="color: blue">&#8216;&gt;
        &lt;</span><span style="color: #a31515">div </span><span style="color: red">class</span><span style="color: blue">=&quot;calendar-day&quot;&gt;
          </span><span style="background: #ffee62">&lt;%</span><span style="color: blue">= </span>task.DueDayOfMonth <span style="background: #ffee62">%&gt;</span><span style="color: blue">&lt;/</span><span style="color: #a31515">div</span><span style="color: blue">&gt;
      &lt;/</span><span style="color: #a31515">div</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: #a31515">td</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">td</span><span style="color: blue">&gt;
      </span><span style="background: #ffee62">&lt;%</span><span style="color: blue">= </span>task.Priority <span style="background: #ffee62">%&gt;
</span>    <span style="color: blue">&lt;/</span><span style="color: #a31515">td</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">td </span><span style="color: red">class</span><span style="color: blue">=&quot;task-title&quot;&gt;
      &lt;</span><span style="color: #a31515">a </span><span style="color: red">href</span><span style="color: blue">=&#8217;</span><span style="background: #ffee62">&lt;%</span>= Href.For(&quot;~/Tasks/{0}/Show.aspx&quot;, task.ID) <span style="background: #ffee62">%&gt;</span><span style="color: blue">&#8216;&gt;</span><span style="background: #ffee62">&lt;%</span><span style="color: blue">= </span>task.Title <span style="background: #ffee62">%&gt;</span><span style="color: blue">&lt;/</span><span style="color: #a31515">a</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: #a31515">td</span><span style="color: blue">&gt;
</span><span style="color: blue">    &lt;</span><span style="color: #a31515">td</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Button </span><span style="color: red">ID</span><span style="color: blue">=&quot;Button1&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">CssClass</span><span style="color: blue">=&quot;button&quot; </span><span style="color: red">CommandName</span><span style="color: blue">=&quot;Delete&quot; </span><span style="color: red">Text</span><span style="color: blue">=&quot;Mark Done&quot; /&gt;
    &lt;/</span><span style="color: #a31515">td</span><span style="color: blue">&gt;
    </span><span style="background: #ffee62">&lt;%
</span>   };

   sections.After = task =&gt; {
    <span style="background: #ffee62">%&gt;
</span>    <span style="color: blue">&lt;/</span><span style="color: #a31515">tr</span><span style="color: blue">&gt;
    </span><span style="background: #ffee62">&lt;%
</span>   };

   sections.AfterAll = task =&gt; {
    <span style="background: #ffee62">%&gt;
</span>    <span style="color: blue">&lt;/</span><span style="color: #a31515">table</span><span style="color: blue">&gt;
    </span><span style="background: #ffee62">&lt;%
</span>   };
 });
<span style="background: #ffee62">%&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste" onclick="javascript:pageTracker._trackVisit('/outbound/article/11011.net');"></a></p>
<p>It might take a while to grasp what&#8217;s going on here. The code actually starts using an Extension method to IEnumerable that looks like this:</p>
<pre class="code"><span style="color: gray">public static void </span>ForEach&lt;T&gt;(<span style="color: gray">this </span><span style="color: #2b91af">IEnumerable</span>&lt;T&gt; enumerable, <span style="color: #2b91af">ForeachSectionSetter</span>&lt;T&gt; sectionSetter) {
  <span style="color: gray">if </span>(enumerable != <span style="color: gray">null</span>) {

    <span style="color: gray">if </span>(sectionSetter != <span style="color: gray">null</span>) {
      <span style="color: #2b91af">ForeachSections</span>&lt;T&gt; sections = <span style="color: gray">new </span><span style="color: #2b91af">ForeachSections</span>&lt;T&gt;();
      sectionSetter(sections);

      <span style="color: gray">if </span>(enumerable.Count() == 0) {
        <span style="color: gray">if </span>(sections.NoData != <span style="color: gray">null</span>)
          sections.NoData(enumerable);
        <span style="color: gray">return</span>;
      }

      <span style="color: gray">if </span>(sections.BeforeAll != <span style="color: gray">null</span>)
        sections.BeforeAll(enumerable);

      <span style="color: gray">int </span>itemIndex = 0;
      T previousItem = <span style="color: gray">default</span>(T);

      <span style="color: gray">foreach </span>(T item <span style="color: gray">in </span>enumerable) {
        <span style="color: gray">if </span>(sections.Before != <span style="color: gray">null</span>)
          sections.Before(item);
        <span style="color: gray">if </span>(itemIndex % 2 == 1 &amp;&amp; sections.Odd != <span style="color: gray">null</span>)
          sections.Odd(item);
        <span style="color: gray">if </span>(itemIndex % 2 == 0 &amp;&amp; sections.Even != <span style="color: gray">null</span>)
          sections.Even(item);
        <span style="color: gray">if </span>(itemIndex &gt; 0 &amp;&amp; sections.Between != <span style="color: gray">null</span>)
          sections.Between(previousItem, item);
        <span style="color: gray">if </span>(sections.Each != <span style="color: gray">null</span>)
          sections.Each(item);
        <span style="color: gray">if </span>(sections.After != <span style="color: gray">null</span>)
          sections.After(item);
        itemIndex++;
        previousItem = item;
      }
      <span style="color: gray">if </span>(sections.AfterAll != <span style="color: gray">null</span>)
        sections.AfterAll(enumerable);
    }
  }
}</pre>
<p><a href="http://11011.net/software/vspaste" onclick="javascript:pageTracker._trackVisit('/outbound/article/11011.net');"></a></p>
<p>The delegate ForEachSectionSetter is used by the calling method with a lambda expression. As a parameter it receives an ForeachSections object, which looks like this:</p>
<pre class="code"><span style="color: gray">public class </span><span style="color: #2b91af">ForeachSections</span>&lt;T&gt; {
  <span style="color: gray">public </span><span style="color: #2b91af">Action</span>&lt;T&gt; Each { <span style="color: gray">get</span>; <span style="color: gray">set</span>; }
  <span style="color: gray">public </span><span style="color: #2b91af">Action</span>&lt;<span style="color: #2b91af">IEnumerable</span>&lt;T&gt;&gt; BeforeAll { <span style="color: gray">get</span>; <span style="color: gray">set</span>; }
  <span style="color: gray">public </span><span style="color: #2b91af">Action</span>&lt;T&gt; Before { <span style="color: gray">get</span>; <span style="color: gray">set</span>; }
  <span style="color: gray">public </span><span style="color: #2b91af">Action</span>&lt;T,T&gt; Between { <span style="color: gray">get</span>; <span style="color: gray">set</span>; }
  <span style="color: gray">public </span><span style="color: #2b91af">Action</span>&lt;T&gt; Odd { <span style="color: gray">get</span>; <span style="color: gray">set</span>; }
  <span style="color: gray">public </span><span style="color: #2b91af">Action</span>&lt;T&gt; Even { <span style="color: gray">get</span>; <span style="color: gray">set</span>; }
  <span style="color: gray">public </span><span style="color: #2b91af">Action</span>&lt;T&gt; After { <span style="color: gray">get</span>; <span style="color: gray">set</span>; }
  <span style="color: gray">public </span><span style="color: #2b91af">Action</span>&lt;<span style="color: #2b91af">IEnumerable</span>&lt;T&gt;&gt; AfterAll { <span style="color: gray">get</span>; <span style="color: gray">set</span>; }
  <span style="color: gray">public </span><span style="color: #2b91af">Action</span>&lt;<span style="color: #2b91af">IEnumerable</span>&lt;T&gt;&gt; NoData { <span style="color: gray">get</span>; <span style="color: gray">set</span>; }
}</pre>
<p><a href="http://11011.net/software/vspaste" onclick="javascript:pageTracker._trackVisit('/outbound/article/11011.net');"></a></p>
<p>The calling method gets the chance to set the properties of this class before it is returned to the constructor of the ForEach method for processing. And because each property is already preset to a default value (Null in this case), the constructor can use the ForeachSections object just like a set of default or optional parameters. The caller can simply set values to the properties it needs, and ignore the rest.</p>
<p>If I had tried this another way, using overloadable constructors, it would have led to multiple constructors with indistinguishable signatures. If I&#8217;d have used property initializers, I wouldn&#8217;t have been able to run the whole routine without requiring a second call to the object, which actually wasn&#8217;t possible. </p>
<p>Basically, I couldn&#8217;t think of another way to do it. </p>
<p>The properties of the ForeachSections object are all delegates too. That means that we can use them with lambdas, which gives us lambdas inside of a lambda. (Hmm, very confusing!)</p>
<p>So what do you think? Could <em>you</em> use something like this? Can you make it simpler? Leave me a comment if you can.</p>


<p><a href="http://feeds.feedburner.com/~a/dotnetSmoothie?a=IaNnXe"><img src="http://feeds.feedburner.com/~a/dotnetSmoothie?i=IaNnXe" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/dotnetSmoothie/~4/302873858" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardbushnell.net/index.php/2008/06/02/c-acrobatics-lambdas-and-expression-methods-as-a-replacement-for-nvelocity/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Value of Being Free to See the Source</title>
		<link>http://richardbushnell.net/index.php/2008/04/18/the-value-of-being-free-to-see-the-source/</link>
		<comments>http://richardbushnell.net/index.php/2008/04/18/the-value-of-being-free-to-see-the-source/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 14:09:54 +0000</pubDate>
		<dc:creator>Richard Bushnell</dc:creator>
		
		<category><![CDATA[ASP.Net]]></category>

		<category><![CDATA[Visual Studio]]></category>

		<category><![CDATA[exceptions]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/04/18/the-value-of-being-free-to-see-the-source/</guid>
		<description><![CDATA[Since the source code to ASP.Net was made available, I&#8217;ve been using it extensively. Here&#8217;s a great example of why it&#8217;s so valuable.
I&#8217;ve been trying to integrate the Enterprise Library 3.1 Exception Handling Block into my application. My application is split into a core and web UI specific components, so I&#8217;ve defined errors in my [...]]]></description>
			<content:encoded><![CDATA[<p>Since the <a href="http://richardbushnell.net/index.php/2008/01/17/net-source-code-now-available/" >source code to ASP.Net was made available</a>, I&#8217;ve been using it extensively. Here&#8217;s a great example of why it&#8217;s so valuable.</p>
<p>I&#8217;ve been trying to integrate the Enterprise Library 3.1 Exception Handling Block into my application. My application is split into a core and web UI specific components, so I&#8217;ve defined errors in my code to be thrown when a resource is not available. The web application configuration file specifies that if a specific exception, e.g. a ResourceNotFoundException, is thrown, the Exception Handling Block should replace that exception with a 404 Resource Not Found error using Http. That should in turn use the CustomErrors feature to redirect to a 404 not found page.</p>
<p>Makes sense, and sounds simple, don&#8217;t you think? </p>
<p>Nothing in the docs says that it shouldn&#8217;t work.</p>
<p><em>But it doesn&#8217;t</em>. It simply <em>won&#8217;t work</em>. Why? Well, there&#8217;s nothing on the web. But after spending some serious hours digging through the source code, I can finally see why.</p>
<p>Here&#8217;s a lovely little hidden-to-the-world snippet of the code I got inside of Visual Studio:</p>
<pre class="code">code = HttpException.GetHttpCodeForException(e);

<span style="color: green">// Don&#8217;t raise event for 404.  See VSWhidbey 124147.
</span><span style="color: blue">if </span>(code != 404) {
  WebBaseEvent.RaiseRuntimeError(e, <span style="color: blue">this</span>);
}</pre>
<p><a href="http://11011.net/software/vspaste" onclick="javascript:pageTracker._trackVisit('/outbound/article/11011.net');"></a>So it would never work! </p>
<p>Nice of them to let me know.</p>


<p><a href="http://feeds.feedburner.com/~a/dotnetSmoothie?a=fw8fYu"><img src="http://feeds.feedburner.com/~a/dotnetSmoothie?i=fw8fYu" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/dotnetSmoothie/~4/272912551" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardbushnell.net/index.php/2008/04/18/the-value-of-being-free-to-see-the-source/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Easy Data-loading with LINQ-to-SQL and LINQ-to-XML</title>
		<link>http://richardbushnell.net/index.php/2008/03/20/easy-data-loading-with-linq-to-sql-and-linq-to-xml-4/</link>
		<comments>http://richardbushnell.net/index.php/2008/03/20/easy-data-loading-with-linq-to-sql-and-linq-to-xml-4/#comments</comments>
		<pubDate>Thu, 20 Mar 2008 07:53:48 +0000</pubDate>
		<dc:creator>Richard Bushnell</dc:creator>
		
		<category><![CDATA[.Net]]></category>

		<category><![CDATA[Development]]></category>

		<category><![CDATA[LINQ]]></category>

		<category><![CDATA[LINQ to SQL]]></category>

		<category><![CDATA[LINQ-to-XML]]></category>

		<category><![CDATA[Software]]></category>

		<category><![CDATA[VB.Net]]></category>

		<category><![CDATA[Visual Studio]]></category>

		<category><![CDATA[data]]></category>

		<category><![CDATA[loading]]></category>

		<category><![CDATA[VB]]></category>

		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/03/20/easy-data-loading-with-linq-to-sql-and-linq-to-xml-4/</guid>
		<description><![CDATA[.Net 3.5 had some nice tricks in it. LINQ-to-XML was one of them. With the new &#34;X&#34;-types, you can make working with XML really easy. 
VB.Net 9 takes it one step further, and lets you write XML in your code without strings.
&#34;Hey Rich, that&#8217;s old news,&#34; I hear you say. &#34;And who&#8217;s interested in VB [...]]]></description>
			<content:encoded><![CDATA[<p>.Net 3.5 had some nice tricks in it. LINQ-to-XML was one of them. With the new &quot;X&quot;-types, you can make working with XML really easy. </p>
<p>VB.Net 9 takes it one step further, and lets you write XML in your code without strings.</p>
<p>&quot;Hey Rich, that&#8217;s old news,&quot; I hear you say. &quot;And who&#8217;s interested in VB today anyway?&quot;</p>
<p>Well, apparently there are a lot of VB-er&#8217;s still out there. I am mainly a C# developer myself, but I found that VB was perfect for a problem I had recently -&#160; loading of XML data into a SQL Server table.</p>
<p> <a href="http://richardbushnell.net/index.php/2008/03/20/easy-data-loading-with-linq-to-sql-and-linq-to-xml-4/#more-98" class="more-link" >(more&#8230;)</a></p>


<p><a href="http://feeds.feedburner.com/~a/dotnetSmoothie?a=0PebAP"><img src="http://feeds.feedburner.com/~a/dotnetSmoothie?i=0PebAP" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/dotnetSmoothie/~4/254766464" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardbushnell.net/index.php/2008/03/20/easy-data-loading-with-linq-to-sql-and-linq-to-xml-4/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Silverlight 2 Poster Available</title>
		<link>http://richardbushnell.net/index.php/2008/03/17/silverlight-2-poster-available/</link>
		<comments>http://richardbushnell.net/index.php/2008/03/17/silverlight-2-poster-available/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 07:52:43 +0000</pubDate>
		<dc:creator>Richard Bushnell</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/03/17/silverlight-2-poster-available/</guid>
		<description><![CDATA[You&#8217;re not a real Silverlight developer until you have the poster stuck up on your wall.
Apparently these were hot at Mix.
Thanks to Brad Abrams for posting it.

]]></description>
			<content:encoded><![CDATA[<p><a href="http://brad_abrams.members.winisp.net/Projects/Mix08SL2Poster/Silverlight2PosterMIX08.jpg" target="_blank" onclick="javascript:pageTracker._trackVisit('/outbound/article/brad_abrams.members.winisp.net');"><img style="border-right: 0px; border-top: 0px; margin: 0px 20px 20px 0px; border-left: 0px; border-bottom: 0px" height="150" alt="image" src="http://richardbushnell.net/wp-content/uploads/2008/03/image11.png" width="240" align="left" border="0" /></a>You&#8217;re not a <em>real</em> Silverlight developer until you have <a href="http://brad_abrams.members.winisp.net/Projects/Mix08SL2Poster/Silverlight2PosterMIX08.jpg" target="_blank" onclick="javascript:pageTracker._trackVisit('/outbound/article/brad_abrams.members.winisp.net');">the poster</a> stuck up on your wall.</p>
<p>Apparently these were hot at Mix.</p>
<p>Thanks to <a href="http://blogs.msdn.com/brada/archive/2008/03/16/silverlight-2-developer-poster.aspx" target="_blank" onclick="javascript:pageTracker._trackVisit('/outbound/article/blogs.msdn.com');">Brad Abrams</a> for posting it.</p>


<p><a href="http://feeds.feedburner.com/~a/dotnetSmoothie?a=j91v83"><img src="http://feeds.feedburner.com/~a/dotnetSmoothie?i=j91v83" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/dotnetSmoothie/~4/252848990" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardbushnell.net/index.php/2008/03/17/silverlight-2-poster-available/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Design Guidelines for LINQ</title>
		<link>http://richardbushnell.net/index.php/2008/03/13/design-guidelines-for-linq/</link>
		<comments>http://richardbushnell.net/index.php/2008/03/13/design-guidelines-for-linq/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 18:40:24 +0000</pubDate>
		<dc:creator>Richard Bushnell</dc:creator>
		
		<category><![CDATA[.Net]]></category>

		<category><![CDATA[C# 3.0]]></category>

		<category><![CDATA[Design]]></category>

		<category><![CDATA[Development]]></category>

		<category><![CDATA[Extension Methods]]></category>

		<category><![CDATA[LINQ]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Software]]></category>

		<category><![CDATA[Guidelines]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/03/13/design-guidelines-for-linq/</guid>
		<description><![CDATA[Have you wondered if and when you should use the new LINQ features in .Net 3.5?
Like, where should I put a new extension method? Should I use Func&#60;T&#62; or a custom delegate? How do I best implement a mix-in (extension methods on an interface)?
Well, Mircea Trofin has just published a new draft of some LINQ [...]]]></description>
			<content:encoded><![CDATA[<p>Have you wondered if and when you should use the new LINQ features in .Net 3.5?</p>
<p>Like, where should I put a new extension method? Should I use Func&lt;T&gt; or a custom delegate? How do I best implement a mix-in (extension methods on an interface)?</p>
<p>Well, Mircea Trofin has just published a new draft of some <a href="http://blogs.msdn.com/mirceat/archive/2008/03/13/linq-framework-design-guidelines.aspx" target="_blank" onclick="javascript:pageTracker._trackVisit('/outbound/article/blogs.msdn.com');">LINQ design guidelines</a>. You might just find your answers there.</p>


<p><a href="http://feeds.feedburner.com/~a/dotnetSmoothie?a=f849ca"><img src="http://feeds.feedburner.com/~a/dotnetSmoothie?i=f849ca" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/dotnetSmoothie/~4/250918424" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardbushnell.net/index.php/2008/03/13/design-guidelines-for-linq/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Read Word Documents in a Web Browser</title>
		<link>http://richardbushnell.net/index.php/2008/03/07/read-word-documents-in-a-web-browser/</link>
		<comments>http://richardbushnell.net/index.php/2008/03/07/read-word-documents-in-a-web-browser/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 07:33:09 +0000</pubDate>
		<dc:creator>Richard Bushnell</dc:creator>
		
		<category><![CDATA[.Net]]></category>

		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/03/07/read-word-documents-in-a-web-browser/</guid>
		<description><![CDATA[ I love this! Not because of the features, but because of the way it works.
Tim Sneath just blogged about TextGlow - an online Word docx file reader. The docx format is XML, and Silverlight 2 apps can use LINQ-to-XML to parse it and format it for display inside the browser.
Amazing!
You can read more about [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.textglow.net/" onclick="javascript:pageTracker._trackVisit('/outbound/article/www.textglow.net');"><img style="border-right: 0px; border-top: 0px; margin: 0px 20px 20px 0px; border-left: 0px; border-bottom: 0px" height="232" alt="image" src="http://richardbushnell.net/wp-content/uploads/2008/03/image10.png" width="240" align="left" border="0" /></a> I love <a href="http://www.textglow.net/" onclick="javascript:pageTracker._trackVisit('/outbound/article/www.textglow.net');">this!</a> Not because of the features, but because of the way it works.</p>
<p><a href="http://blogs.msdn.com/tims/archive/2008/03/06/a-great-early-silverlight-2-showcase-textglow.aspx" onclick="javascript:pageTracker._trackVisit('/outbound/article/blogs.msdn.com');">Tim Sneath</a> just blogged about <a href="http://www.textglow.net/" onclick="javascript:pageTracker._trackVisit('/outbound/article/www.textglow.net');">TextGlow</a> - an online Word docx file reader. The docx format is XML, and Silverlight 2 apps can use LINQ-to-XML to parse it and format it for display inside the browser.</p>
<p>Amazing!</p>
<p>You can read more about it on <a href="http://blogs.msdn.com/tims/archive/2008/03/06/a-great-early-silverlight-2-showcase-textglow.aspx" onclick="javascript:pageTracker._trackVisit('/outbound/article/blogs.msdn.com');">Tim&#8217;s blog</a>.</p>


<p><a href="http://feeds.feedburner.com/~a/dotnetSmoothie?a=tHz1pr"><img src="http://feeds.feedburner.com/~a/dotnetSmoothie?i=tHz1pr" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/dotnetSmoothie/~4/247233864" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardbushnell.net/index.php/2008/03/07/read-word-documents-in-a-web-browser/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Mix 08 WPF Scheduling Application</title>
		<link>http://richardbushnell.net/index.php/2008/03/05/mix-08-wpf-scheduling-application/</link>
		<comments>http://richardbushnell.net/index.php/2008/03/05/mix-08-wpf-scheduling-application/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 08:41:59 +0000</pubDate>
		<dc:creator>Richard Bushnell</dc:creator>
		
		<category><![CDATA[.Net]]></category>

		<category><![CDATA[Design]]></category>

		<category><![CDATA[WPF]]></category>

		<category><![CDATA[Apps]]></category>

		<category><![CDATA[Mix08]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/03/05/mix-08-wpf-scheduling-application/</guid>
		<description><![CDATA[Mix 08 seems to be much more mature than ever before. In previous years there were a lot of ideas being spoken about; this year there are much more implementations of those ideas available to look at. It seems like a lot of people have been working on the new technologies over the past year [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://richardbushnell.net/wp-content/uploads/2008/03/image5.png" ><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 20px 20px 0px; border-right-width: 0px" height="186" alt="image" src="http://richardbushnell.net/wp-content/uploads/2008/03/image-thumb3.png" width="136" align="left" border="0" /></a>Mix 08 seems to be much more mature than ever before. In previous years there were a lot of ideas being spoken about; this year there are much more implementations of those ideas available to look at. It seems like a lot of people have been working on the new technologies over the past year or so. Hopefully that will lead to the ripening of many technologies (especially WPF) to a point where we can actually use them.</p>
<p>As an example, there is a <a href="http://thirteen23.com/experiences/desktop/mix08/" onclick="javascript:pageTracker._trackVisit('/outbound/article/thirteen23.com');">scheduling application</a> available for Mix. Unfortunately it only runs on Vista, but I captured a video and made a few screenshots for you.</p>
<p>This is the opening screen, with an agenda for the 4 days of the event:</p>
<p><a href="http://richardbushnell.net/wp-content/uploads/2008/03/image8.png" ><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 40px 0px 0px; width: 420px; border-right-width: 0px" height="334" alt="image" src="http://richardbushnell.net/wp-content/uploads/2008/03/image-thumb6.png" width="420" border="0" /></a></p>
<p>(Click the image to make it larger.)</p>
<p> <a href="http://richardbushnell.net/index.php/2008/03/05/mix-08-wpf-scheduling-application/#more-78" class="more-link" >(more&#8230;)</a></p>


<p><a href="http://feeds.feedburner.com/~a/dotnetSmoothie?a=NGdjpH"><img src="http://feeds.feedburner.com/~a/dotnetSmoothie?i=NGdjpH" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/dotnetSmoothie/~4/246003993" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardbushnell.net/index.php/2008/03/05/mix-08-wpf-scheduling-application/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Silverlight for Nokia Phones</title>
		<link>http://richardbushnell.net/index.php/2008/03/05/silverlight-for-nokia-phones/</link>
		<comments>http://richardbushnell.net/index.php/2008/03/05/silverlight-for-nokia-phones/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 06:45:45 +0000</pubDate>
		<dc:creator>Richard Bushnell</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/03/05/silverlight-for-nokia-phones/</guid>
		<description><![CDATA[ BBC News has just released an article referring to a deal made between Microsoft and Nokia to put Silverlight on mobile phones.
Yet another reason to get polishing those WPF skills.

]]></description>
			<content:encoded><![CDATA[<p><a href="http://richardbushnell.net/wp-content/uploads/2008/03/image4.png" ><img style="border-right: 0px; border-top: 0px; margin: 0px 20px 20px 0px; border-left: 0px; border-bottom: 0px" height="152" alt="image" src="http://richardbushnell.net/wp-content/uploads/2008/03/image-thumb2.png" width="203" align="left" border="0"></a> BBC News has just released an article referring to a <a href="http://news.bbc.co.uk/2/hi/science/nature/7276907.stm" target="_blank" onclick="javascript:pageTracker._trackVisit('/outbound/article/news.bbc.co.uk');">deal made between Microsoft and Nokia to put Silverlight on mobile phones</a>.</p>
<p>Yet another reason to get polishing those WPF skills.</p>


<p><a href="http://feeds.feedburner.com/~a/dotnetSmoothie?a=wNj0hQ"><img src="http://feeds.feedburner.com/~a/dotnetSmoothie?i=wNj0hQ" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/dotnetSmoothie/~4/245957281" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardbushnell.net/index.php/2008/03/05/silverlight-for-nokia-phones/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Mix 08 Online Presentations</title>
		<link>http://richardbushnell.net/index.php/2008/03/04/mix-08-online-presentations/</link>
		<comments>http://richardbushnell.net/index.php/2008/03/04/mix-08-online-presentations/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 06:06:54 +0000</pubDate>
		<dc:creator>Richard Bushnell</dc:creator>
		
		<category><![CDATA[.Net]]></category>

		<category><![CDATA[ASP.Net]]></category>

		<category><![CDATA[Mix08]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/03/04/mix-08-online-presentations/</guid>
		<description><![CDATA[My favorite conference is about to start: MIX 08. 
It&#8217;s a great conference for Microsoft developers with an interest in the web. Last year they had some great talks about user experience and architecture. There&#8217;s always something interesting to learn.
Unfortunately I can&#8217;t be there (as usual), but all the sessions will be online. Tim Sneath [...]]]></description>
			<content:encoded><![CDATA[<p>My favorite conference is about to start: MIX 08. </p>
<p>It&#8217;s a great conference for Microsoft developers with an interest in the web. Last year they had some great talks about user experience and architecture. There&#8217;s always something interesting to learn.</p>
<p>Unfortunately I can&#8217;t be there (as usual), but all the sessions will be online. Tim Sneath just posted <a href="http://blogs.msdn.com/tims/archive/2008/03/03/mix08-for-non-attendees.as" target="_blank" onclick="javascript:pageTracker._trackVisit('/outbound/article/blogs.msdn.com');">details of where and when you can watch them:</a></p>
<ul>
<li>The keynote with Ray Ozzie, Scott Guthrie will be available <em>live</em> at 9:30am Pacific / 5:30pm GMT on three streams: <a href="http://wm.istreamplanet.com/customers/ms/750_microsoft_mix_080305.asx" onclick="javascript:pageTracker._trackVisit('/outbound/article/wm.istreamplanet.com');">750kbps</a>, <a href="http://wm.istreamplanet.com/customers/ms/300_microsoft_mix_080305.asx" onclick="javascript:pageTracker._trackVisit('/outbound/article/wm.istreamplanet.com');">300kbps</a>, <a href="http://wm.istreamplanet.com/customers/ms/100_microsoft_mix_080305.asx" onclick="javascript:pageTracker._trackVisit('/outbound/article/wm.istreamplanet.com');">100kbps</a>. </li>
<li>The breakout sessions and panels will be online within 24 hours of each session at <a href="http://sessions.visitmix.com/" onclick="javascript:pageTracker._trackVisit('/outbound/article/sessions.visitmix.com');">MIX08 sessions</a>.</li>
</ul>


<p><a href="http://feeds.feedburner.com/~a/dotnetSmoothie?a=Hkc3rB"><img src="http://feeds.feedburner.com/~a/dotnetSmoothie?i=Hkc3rB" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/dotnetSmoothie/~4/245312684" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardbushnell.net/index.php/2008/03/04/mix-08-online-presentations/feed/</wfw:commentRss>
<enclosure url="http://wm.istreamplanet.com/customers/ms/750_microsoft_mix_080305.asx" length="566" type="video/x-ms-asf" />
<enclosure url="http://wm.istreamplanet.com/customers/ms/300_microsoft_mix_080305.asx" length="566" type="video/x-ms-asf" />
<enclosure url="http://wm.istreamplanet.com/customers/ms/100_microsoft_mix_080305.asx" length="566" type="video/x-ms-asf" />
		</item>
		<item>
		<title>ExtensionMethod.net - An Extension Methods Database</title>
		<link>http://richardbushnell.net/index.php/2008/03/03/extensionmethodnet-an-extension-methods-database/</link>
		<comments>http://richardbushnell.net/index.php/2008/03/03/extensionmethodnet-an-extension-methods-database/#comments</comments>
		<pubDate>Mon, 03 Mar 2008 20:32:03 +0000</pubDate>
		<dc:creator>Richard Bushnell</dc:creator>
		
		<category><![CDATA[.Net]]></category>

		<category><![CDATA[C# 3.0]]></category>

		<category><![CDATA[Development]]></category>

		<category><![CDATA[Extension Methods]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/03/03/extensionmethodnet-an-extension-methods-database/</guid>
		<description><![CDATA[While surfing around tonight, I came across ExtensionMethod.net, a database of useful Extension Methods for C# 3.0 and VB 9. I thought it might be useful, so I added a few of my own extension methods.

IComparable&#60;T&#62;.LessThan
int.Times
int.To

There aren&#8217;t many there yet, but there are one or two on there from Scott Guthrie. 
Have you got any [...]]]></description>
			<content:encoded><![CDATA[<p>While surfing around tonight, I came across <a href="http://www.extensionmethod.net/" target="_blank" onclick="javascript:pageTracker._trackVisit('/outbound/article/www.extensionmethod.net');">ExtensionMethod.net</a>, a database of useful Extension Methods for C# 3.0 and VB 9. I thought it might be useful, so I added a few of my own extension methods.</p>
<ul>
<li><a href="http://www.extensionmethod.net/" target="_blank" onclick="javascript:pageTracker._trackVisit('/outbound/article/www.extensionmethod.net');">IComparable&lt;T&gt;.LessThan</a></li>
<li><a href="http://www.extensionmethod.net/Details.aspx?ID=85" target="_blank" onclick="javascript:pageTracker._trackVisit('/outbound/article/www.extensionmethod.net');">int.Times</a></li>
<li><a href="http://www.extensionmethod.net/Details.aspx?ID=84" target="_blank" onclick="javascript:pageTracker._trackVisit('/outbound/article/www.extensionmethod.net');">int.To</a></li>
</ul>
<p>There aren&#8217;t many there yet, but there are one or two on there from Scott Guthrie. </p>
<p>Have you got any code you could put up there? You could be one of the first if you go now.</p>


<p><a href="http://feeds.feedburner.com/~a/dotnetSmoothie?a=xThYeU"><img src="http://feeds.feedburner.com/~a/dotnetSmoothie?i=xThYeU" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/dotnetSmoothie/~4/245075279" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardbushnell.net/index.php/2008/03/03/extensionmethodnet-an-extension-methods-database/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
