﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>Dennis' Blog</title>
    <item>
      <title>What is TypeScript and why should I care ? </title>
      <link>/2012/10/what-is-typescript</link>
      <description>&lt;p&gt;This tuesday, I watched Anders Hejlsberg present Microsoft's new language bet, &lt;a href="http://www.typescriptlang.org/"&gt;TypeScript&lt;/a&gt;. This is basically JavaScript with types. It compiles to JavaScript, so, at runtime, it &lt;em&gt;is&lt;/em&gt; JavaScript, nothing else. And therefore, it will run whereever JavaScript can run: In any browser, on node.js and so on.&lt;/p&gt;

&lt;p&gt;TypeScript adds types as a first class citizen to JavaScript. This means you can use classes and interfaces in your code, and have the compiler do type checking. TypeScript is compiled to the idiomatic JavaScript, we would have to write ourselves, if we want to do object oriented programming in JavaScript. It also adds modules, and a bit nicer anonymous function syntax. Already available is some really nice tooling for Visual Studio 2012. &lt;/p&gt;

&lt;p&gt;This is an example of how a snippet of TypeScript looks:&lt;/p&gt;

&lt;pre&gt;&lt;code class="prettyprint"&gt;class Greeter {
    greeting: string;
    constructor (message: string) {
        this.greeting = message;
    }
    greet() {
        return "Hello, " + this.greeting;
    }
}   

var greeter = new Greeter("world");
var greeting = greeter.greet();
&lt;/code&gt;&lt;/pre&gt;

&lt;h1&gt;Why should I care ?&lt;/h1&gt;

&lt;p&gt;We are building larger and larger applications in JavaScript. This is true both to support great user experiences on the web, but JavaScript is also used more and more for many other purposes: You can create standalone applications or servers in node.js, you can use HTML+JavaScript for Windows 8 programs and other platforms. The lack of types in JavaScript means that development and debugging time can be slowed down, and bugs can be hard to find.&lt;/p&gt;

&lt;p&gt;You might not agree with this, but consider: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Have you ever misspelled a method in JavaScript, and not found out until that exact method ? This does not happen with TypeScript.&lt;/li&gt;
&lt;li&gt;Ever had to look some method signature up in the jQuery documentation, then spending time on Google to find the right one - with the TypeScript tools, you get auto completion right in the editor (Visual Studio for now).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Basically you get all the safety nets of a statically typed language, while still having all the benefits from JavaScript. The static typing also allows for features like auto-completion and refactoring support. One of the core benefits from using TypeScript is added tool support, and in turn, developer productivity.  &lt;/p&gt;

&lt;h1&gt;Is this not just a rip-off of CoffeeScript ?&lt;/h1&gt;

&lt;p&gt;No, I don't think so. CoffeeScript is about fixing the syntax of JavaScript, but it does not touch the type system. This is the core difference betweeen the two. You might like or dislike the CoffeeScript syntax, but the CoffeeScript compiler is not aware of types.&lt;/p&gt;

&lt;p&gt;I think TypeScript does a good job of keeping a familiar syntax, while reducing the amount of typing needed to create, for instance, a class. TypeScript also does automatic capture of the &lt;code class="prettyprint"&gt;this&lt;/code&gt; variable for anonymous functions, which is very neat.&lt;/p&gt;

&lt;h1&gt;Go try it out&lt;/h1&gt;

&lt;p&gt;You can download the bits for VS or node.js &lt;a href="http://www.typescriptlang.org/#Download"&gt;here&lt;/a&gt;, and there is also an &lt;a href="http://www.typescriptlang.org/Playground/"&gt;online playground&lt;/a&gt;, where you can run TypeScript directly in your browser. It's a preview, but is seems pretty stable to me.&lt;/p&gt;

&lt;p&gt;Maybe it is not for you, maybe you are the dynamic language type of guy - But, I am excited about this and for fans of static typing, this is great news. &lt;/p&gt;

&lt;p&gt;I might even get excited about the prospect of building a node.js app now.&lt;/p&gt;
</description>
      <pubDate>Fri, 05 Oct 2012 17:05:10 UTC</pubDate>
    </item>
    <item>
      <title>A new home for the Chrome Password Recovery Tool</title>
      <link>/2011/04/new-home-for-chrome-password-recovery-tool</link>
      <description>&lt;p&gt;In 2008, I created the &lt;a href="http://www.driis.dk/2008/12/Introducing-The-Google-Chrome-Password-Recovery-Tool"&gt;Chrome Password Recovery Tool&lt;/a&gt;. However, the download links on that page have been lost in a server migration. &lt;/p&gt;

&lt;p&gt;Since I have been getting some email about the absence of a download of the tool, I decided to release it as open source on CodePlex. So &lt;a href="http://cprecover.codeplex.com/"&gt;go get it from here&lt;/a&gt;, if you need it.&lt;/p&gt;

&lt;p&gt;This latest version supports the latest Chrome version (10), and enables reading the passwords while Chrome is running.&lt;/p&gt;
</description>
      <pubDate>Wed, 13 Apr 2011 20:46:24 UTC</pubDate>
    </item>
    <item>
      <title>This blog now running MVC3 and RavenDB !</title>
      <link>/2011/03/blog-now-running-mvc3-and-ravendb</link>
      <description>&lt;p&gt;From today, this blog will be running a home-grown blogging system built on MVC3, Razor and RavenDB.&lt;/p&gt;

&lt;p&gt;It had been running Sitecore Express until now, but i decided to ditch it. A Sitecore installation is simply too much of a hassle for a simple site like this. Also, the rich text editor in Sitecore was not really fit for posting code snippets. I will be refining this new blogging solution over the next few weeks, and hopefully it will give me a renewed interest in actually posting content on this blog :-)&lt;/p&gt;

&lt;p&gt;I built this blogging system myself (no CMS or other framework base) to learn more about MVC3 and RavenDB. Conlusion: MVC3 is nice, Razor view syntax is &lt;em&gt;extremely cool&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;RavenDB is also easy to get started with and to learn. It is what I would call a no-frills NoSQL document database. So if one has data storage needs that fit into the NoSQL camp, and is building on .NET, i think the choice is a no-brainer. You do have to be aware that it is still a young product, which is changing rapidly. &lt;/p&gt;
</description>
      <pubDate>Sun, 06 Mar 2011 18:51:56 UTC</pubDate>
    </item>
    <item>
      <title>A Relative Path Facility For Castle Windsor</title>
      <link>/2010/02/A-Relative-Path-Facility-For-Castle-Windsor</link>
      <description>
		&lt;p&gt;At work, we use &lt;a title="Castle Project" href="http://www.castleproject.org/container/index.html" target="_blank"&gt;Castle Windsor&lt;/a&gt; for &lt;a title="DI on Wikipedia" href="http://en.wikipedia.org/wiki/Dependency_injection" target="_blank"&gt;Dependency Injection&lt;/a&gt;. In Castle Windsor, as with any dependency injection framework, you can configure components identified by an interface, that can be resolved at runtime using the dependency injection framework. Components can have dependencies, which can be yet other components and so on. In this way, you can have your dependency injection framework create a whole graph of objects for you.&lt;/p&gt;
    &lt;p&gt;One limitation we run into now and then, is with components, that depend on a file path to work. Typically, we need to know the full path of the file to load it. But hardcoding the full path in the configuration file is generally a bad idea, it will create problems when you move your web application between environments. Also, we cannot just pass the path as a virtual path to the component and then have the component call Server.MapPath to map the path - since that would mean changing the interface of the component just to accomodate the injection framework, which is not a good idea. And, what is worse, you would create a dependency on System.Web in a place where it probably isn't needed.&lt;/p&gt;
    &lt;p&gt;Now, one way to get around this would be to create a wrapper interface, IFilePath, which only should exist in order to be passed into the component and being able to convert the path. This also involves changing the component and generally feels like a bad idea.&lt;/p&gt;
    &lt;p&gt;Luckily, the Windsor IoC container offers a large variety of extension points - one being &lt;a href="http://www.castleproject.org/container/documentation/trunk/concepts/facility.html"&gt;facilities&lt;/a&gt;. So I wrote a facility, that allows paths configured in Castle Windsor to be relative. The way this works is by registering an &lt;em&gt;ISubDependencyResolver &lt;/em&gt;in the &lt;em&gt;IKernel &lt;/em&gt;instance. When resolving a dependency, Windsor will ask the &lt;em&gt;ISubDependencyResolver &lt;/em&gt;whether it can resolve the dependency using the &lt;em&gt;CanResolve &lt;/em&gt;method. By examining the passed ComponentModel and in particular it's configuration node, I look for a custom attribute on the dependency, pathType. If found (and the dependency is of type string), then we can easily resolve the dependency by taking the relative path in the configuration tag and making it absolute.&lt;/p&gt;
    &lt;p&gt;This will allow you to have your Windsor configuration look like this (notice the one-line facility registration - this is what registers the custom facility in Windsor, and makes us able to register the &lt;em&gt;path &lt;/em&gt;dependency as a virtual path):&lt;/p&gt;
    &lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
    &lt;div class="csharpcode"&gt;
      &lt;pre class="alt"&gt;        &lt;span class="lnum"&gt; 1: &lt;/span&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;castle&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;        &lt;span class="lnum"&gt; 2: &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;facilities&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;        &lt;span class="lnum"&gt; 3: &lt;/span&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;facility&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="pathResolver"&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="dr.Castle.WebPathFacility.RelativePathSupportFacility, dr.Castle.WebPathFacility"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;        &lt;span class="lnum"&gt; 4: &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;facilities&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;        &lt;span class="lnum"&gt; 5: &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;components&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;        &lt;span class="lnum"&gt; 6: &lt;/span&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;component&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="dummy"&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;        &lt;span class="lnum"&gt; 7: &lt;/span&gt;                 &lt;span class="attr"&gt;service&lt;/span&gt;&lt;span class="kwrd"&gt;="dr.Castle.WebPathFacility.Test.IDummy, dr.Castle.WebPathFacility.Test"&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;        &lt;span class="lnum"&gt; 8: &lt;/span&gt;                 &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="dr.Castle.WebPathFacility.Test.Dummy, dr.Castle.WebPathFacility.Test"&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;        &lt;span class="lnum"&gt; 9: &lt;/span&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;parameters&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;        &lt;span class="lnum"&gt; 10: &lt;/span&gt;          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;path&lt;/span&gt; &lt;span class="attr"&gt;pathType&lt;/span&gt;&lt;span class="kwrd"&gt;="Relative"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;App_Data/test.xml&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;path&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;        &lt;span class="lnum"&gt; 11: &lt;/span&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;parameters&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;        &lt;span class="lnum"&gt; 12: &lt;/span&gt;      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;component&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;        &lt;span class="lnum"&gt; 13: &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;components&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;        &lt;span class="lnum"&gt; 14: &lt;/span&gt;  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;castle&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt; &lt;/pre&gt;
    &lt;/div&gt;
    &lt;p&gt;The valid values for pathType are: &lt;/p&gt;
    &lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
    &lt;div class="csharpcode"&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 1: &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; PathType&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 2: &lt;/span&gt;        {&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 3: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 4: &lt;/span&gt;            &lt;span class="rem"&gt;/// The path is absolute (we will do nothing to it).&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 5: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 6: &lt;/span&gt;            Absolute = 0,&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 7: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 8: &lt;/span&gt;            &lt;span class="rem"&gt;/// The path is a virtual path to a web application resource.&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 9: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 10: &lt;/span&gt;            Virtual,&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 11: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 12: &lt;/span&gt;            &lt;span class="rem"&gt;/// The path is relative to the current directory.&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 13: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 14: &lt;/span&gt;            Relative&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 15: &lt;/span&gt;        }&lt;/pre&gt;
    &lt;/div&gt;
    &lt;p&gt;The code for the facility it self is really simple, since it simply registers our dependency resolver to the Kernel. The advantage of using a facility, is that it can be declared in the config, and Windsor will automatically initialize for all containers you create: &lt;/p&gt;
    &lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
    &lt;div class="csharpcode"&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 1: &lt;/span&gt;
        &lt;span class="kwrd"&gt;using&lt;/span&gt; Castle.MicroKernel.Facilities;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 2: &lt;/span&gt; &lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 3: &lt;/span&gt;
        &lt;span class="kwrd"&gt;namespace&lt;/span&gt; dr.Castle.WebPathFacility&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 4: &lt;/span&gt;{&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 5: &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; RelativePathSupportFacility : AbstractFacility&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 6: &lt;/span&gt;    {&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 7: &lt;/span&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Init()&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 8: &lt;/span&gt;        {&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 9: &lt;/span&gt;            Kernel.Resolver.AddSubResolver(&lt;span class="kwrd"&gt;new&lt;/span&gt; PathParameterDependencyResolver());            &lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 10: &lt;/span&gt;        }&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 11: &lt;/span&gt;    }&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 12: &lt;/span&gt;}&lt;/pre&gt;
    &lt;/div&gt;
    &lt;p&gt;Finally, the implementation of ISubDependencyResolver, that makes this possible:&lt;/p&gt;
    &lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
    &lt;div class="csharpcode"&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 1: &lt;/span&gt;
        &lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 2: &lt;/span&gt;
        &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 3: &lt;/span&gt;
        &lt;span class="kwrd"&gt;using&lt;/span&gt; System.IO;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 4: &lt;/span&gt;
        &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 5: &lt;/span&gt;
        &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 6: &lt;/span&gt;
        &lt;span class="kwrd"&gt;using&lt;/span&gt; Castle.Core;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 7: &lt;/span&gt;
        &lt;span class="kwrd"&gt;using&lt;/span&gt; Castle.MicroKernel;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 8: &lt;/span&gt; &lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 9: &lt;/span&gt;
        &lt;span class="kwrd"&gt;namespace&lt;/span&gt; dr.Castle.WebPathFacility&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 10: &lt;/span&gt;{&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 11: &lt;/span&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 12: &lt;/span&gt;    &lt;span class="rem"&gt;/// Custom dependency resolver, that will inspect the parameters collection for the pathType attribute, and, if found, convert the dependency to &lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 13: &lt;/span&gt;    &lt;span class="rem"&gt;/// a absolute path based on the path type.&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 14: &lt;/span&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 15: &lt;/span&gt;    &lt;span class="kwrd"&gt;class&lt;/span&gt; PathParameterDependencyResolver : ISubDependencyResolver&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 16: &lt;/span&gt;    {&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 17: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 18: &lt;/span&gt;        &lt;span class="rem"&gt;/// Holds the supported conversion operations.&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 19: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 20: &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; Dictionary&amp;lt;PathType,Func&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;&amp;gt; conversions = &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;PathType, Func&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;&amp;gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 21: &lt;/span&gt;                                                                                           {&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 22: &lt;/span&gt;                                                                                               {PathType.Absolute, path =&amp;gt; path},&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 23: &lt;/span&gt;                                                                                               {PathType.Relative, path =&amp;gt; Path.Combine(Environment.CurrentDirectory,path) },&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 24: &lt;/span&gt;                                                                                               {PathType.Virtual,  path =&amp;gt; HttpContext.Current.Server.MapPath(path)}&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 25: &lt;/span&gt;                                                                                           };&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 26: &lt;/span&gt; &lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 27: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 28: &lt;/span&gt;        &lt;span class="rem"&gt;/// Cache of the type path parameters.&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 29: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 30: &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;,PathParameter&amp;gt; typePathParameters = &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, PathParameter&amp;gt;();&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 31: &lt;/span&gt; &lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 32: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 33: &lt;/span&gt;        &lt;span class="rem"&gt;/// Resolves the specified dependency.&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 34: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 35: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="context"&amp;gt;Creation context&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 36: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="contextHandlerResolver"&amp;gt;Parent resolver&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 37: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="model"&amp;gt;Model of the component that is requesting the dependency&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 38: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="dependency"&amp;gt;The dependcy to satisfy&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 39: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if the dependency can be satsfied by this resolver, else &amp;lt;c&amp;gt;false&amp;lt;/c&amp;gt;.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 40: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;The resolved dependency&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 41: &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 42: &lt;/span&gt;        {&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 43: &lt;/span&gt;            PathParameter parameter = GetPathParameter(model, dependency);&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 44: &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (parameter == &lt;span class="kwrd"&gt;null&lt;/span&gt;) &lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 45: &lt;/span&gt;                &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ApplicationException(String.Format(&lt;span class="str"&gt;"Cannot resolve dependency {0}"&lt;/span&gt;, dependency));&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 46: &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!conversions.ContainsKey(parameter.Type))&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 47: &lt;/span&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; parameter.Value;     &lt;span class="rem"&gt;// Unknown conversion&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 48: &lt;/span&gt; &lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 49: &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; conversions[parameter.Type](parameter.Value);&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 50: &lt;/span&gt;        }&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 51: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 52: &lt;/span&gt;        &lt;span class="rem"&gt;/// Determines whether this sub dependency resolver can resolve the specified dependency.&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 53: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 54: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="context"&amp;gt;Creation context&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 55: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="contextHandlerResolver"&amp;gt;Parent resolver&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 56: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="model"&amp;gt;Model of the component that is requesting the dependency&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 57: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="dependency"&amp;gt;The dependcy to satisfy&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 58: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if the dependency can be satsfied by this resolver, else &amp;lt;c&amp;gt;false&amp;lt;/c&amp;gt;.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 59: &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 60: &lt;/span&gt;        {            &lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 61: &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; ( dependency.DependencyType == DependencyType.Parameter &amp;amp;&amp;amp; dependency.TargetType.Equals(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;string&lt;/span&gt;)) )&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 62: &lt;/span&gt;            {&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 63: &lt;/span&gt;                PathParameter parameter = GetPathParameter(model, dependency);&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 64: &lt;/span&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; parameter != &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 65: &lt;/span&gt;            }&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 66: &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 67: &lt;/span&gt;        }&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 68: &lt;/span&gt; &lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 69: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 70: &lt;/span&gt;        &lt;span class="rem"&gt;/// Finds the parameter by looking at the cache, then in the model configuration.&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 71: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 72: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="model"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 73: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="dependency"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 74: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 75: &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; PathParameter GetPathParameter(ComponentModel model, DependencyModel dependency)&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 76: &lt;/span&gt;        {&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 77: &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!typePathParameters.ContainsKey(model.Name))&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 78: &lt;/span&gt;                typePathParameters.Add(model.Name, GetPathParameterInternal(model, dependency));&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 79: &lt;/span&gt; &lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 80: &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; typePathParameters[model.Name];&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 81: &lt;/span&gt;        }&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 82: &lt;/span&gt; &lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 83: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 84: &lt;/span&gt;        &lt;span class="rem"&gt;/// Finds the parameter by looking at the model configuration.&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 85: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 86: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="model"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 87: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="dependency"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 88: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 89: &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; PathParameter GetPathParameterInternal(ComponentModel model, DependencyModel dependency)&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 90: &lt;/span&gt;        {&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 91: &lt;/span&gt;            var parametersContainer = model.Configuration.Children.SingleOrDefault(n =&amp;gt; n.Name == &lt;span class="str"&gt;"parameters"&lt;/span&gt;);&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 92: &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; ( parametersContainer != &lt;span class="kwrd"&gt;null&lt;/span&gt; )&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 93: &lt;/span&gt;            {&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 94: &lt;/span&gt;                var parameterNode = parametersContainer.Children.SingleOrDefault(n =&amp;gt; n.Name == dependency.DependencyKey);&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 95: &lt;/span&gt;                &lt;span class="kwrd"&gt;string&lt;/span&gt; pathType = parameterNode.Attributes[&lt;span class="str"&gt;"pathType"&lt;/span&gt;];&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 96: &lt;/span&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (pathType != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 97: &lt;/span&gt;                {&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 98: &lt;/span&gt;                    PathType type;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 99: &lt;/span&gt;                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (!Enum.TryParse(pathType, &lt;span class="kwrd"&gt;true&lt;/span&gt;, &lt;span class="kwrd"&gt;out&lt;/span&gt; type))&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 100: &lt;/span&gt;                        &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ApplicationException(&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 101: &lt;/span&gt;                            String.Format(&lt;span class="str"&gt;"Configuration error: Invalid pathType value '{0}'"&lt;/span&gt;, pathType));&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 102: &lt;/span&gt; &lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 103: &lt;/span&gt;                    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; PathParameter {Type = type, Value = parameterNode.Value};&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 104: &lt;/span&gt;                }&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 105: &lt;/span&gt;            }&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 106: &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 107: &lt;/span&gt;        }&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 108: &lt;/span&gt; &lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 109: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 110: &lt;/span&gt;        &lt;span class="rem"&gt;/// Holds a path parameter&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 111: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 112: &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; PathParameter&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 113: &lt;/span&gt;        {&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 114: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 115: &lt;/span&gt;            &lt;span class="rem"&gt;/// Value as entered in config&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 116: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 117: &lt;/span&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Value { get; set; }&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 118: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 119: &lt;/span&gt;            &lt;span class="rem"&gt;/// Type of path.&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 120: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 121: &lt;/span&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; PathType Type { get; set;}&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 122: &lt;/span&gt;        }&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 123: &lt;/span&gt; &lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 124: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 125: &lt;/span&gt;        &lt;span class="rem"&gt;/// Defines the types of paths supported by &amp;lt;see cref="PathParameterDependencyResolver" /&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 126: &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 127: &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; PathType&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 128: &lt;/span&gt;        {&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 129: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 130: &lt;/span&gt;            &lt;span class="rem"&gt;/// The path is absolute (we will do nothing to it).&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 131: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 132: &lt;/span&gt;            Absolute = 0,&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 133: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 134: &lt;/span&gt;            &lt;span class="rem"&gt;/// The path is a virtual path to a web application resource.&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 135: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 136: &lt;/span&gt;            Virtual,&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 137: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 138: &lt;/span&gt;            &lt;span class="rem"&gt;/// The path is relative to the current directory.&lt;/span&gt;&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 139: &lt;/span&gt;            &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 140: &lt;/span&gt;            Relative&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 141: &lt;/span&gt;        }&lt;/pre&gt;
      &lt;pre&gt;
        &lt;span class="lnum"&gt; 142: &lt;/span&gt;    }&lt;/pre&gt;
      &lt;pre class="alt"&gt;
        &lt;span class="lnum"&gt; 143: &lt;/span&gt;}&lt;/pre&gt;
    &lt;/div&gt;
    &lt;p&gt;Now, I am finally able to use virtual paths in my configuration files, with a minimum of noise. Great. Please notice, that the "Relative" path type might not make sense for a real application (since it uses Environment.CurrentDirectory as base), but it can be really helpful in test configurations. The primary reason for creating this is pathType="virtual", which maps to &lt;a title="MSDN HttpServerUtility.MapPath" href="http://msdn.microsoft.com/en-us/library/ms524632.aspx" target="_blank"&gt;Server.MapPath&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Mon, 22 Feb 2010 22:25:00 UTC</pubDate>
    </item>
    <item>
      <title>Using Expression Trees To Break The Law Of Demeter</title>
      <link>/2010/01/Using-Expression-Trees-To-Break-The-Law-Of-Demeter</link>
      <description>I am sure most programmers have heard about the &lt;a title="Law Of Demeter on Wikipedia" href="http://en.wikipedia.org/wiki/Law_of_Demeter" target="ext"&gt;Law Of Demeter&lt;/a&gt;, which is the principle that a classshould only have limited knowledge about other classes, and only talk to objects closely related to the current object. This is sometimes presented as "you should not have more than one dot in each expression". In other words, this would be breaking the law: &lt;p&gt;&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&lt;br /&gt;string&lt;/span&gt; name = order.Customer.Name;&lt;/pre&gt;&lt;p&gt;  &lt;/p&gt;&lt;p&gt;While I do appreciate the idea behind the Law Of Demeter, specifically that individual classes should not know too much about each other; I think the above code would often be perfectly acceptable. &lt;a title="Phil Haack's blog" href="http://haacked.com/" target="ext"&gt;Phil Haack&lt;/a&gt; has a blogpost going into further details about this: &lt;a title="Phil Haack on the Law of Demeter" href="http://haacked.com/archive/2009/07/14/law-of-demeter-dot-counting.aspx" target="ext"&gt;The Law of Demeter Is Not A Dot Counting Excercise&lt;/a&gt;, and &lt;a title="Dan Mange on the Law of Demeter" href="http://www.dcmanges.com/blog/37" target="ext"&gt;others agree&lt;/a&gt;. &lt;span style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: DA"&gt;I think Martin Fowler explains it best: "&lt;a title="Martin Fowler quote" href="http://twitter.com/martinfowler/status/1649793241" target="ext"&gt;I'd prefer to call it the Occasional Useful Suggestion of Demeter&lt;/a&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: DA"&gt;". &lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: DA"&gt;So, most of us will probably (hopefully) agree, that it is OK to use more than one dot in a statement, when appropiate. One such place might be when doing UI in a ASP .NET application, and one needs to display information about an order and it's details. But here arises a problem, we will need to check each of the expression parts for null to ensure that we do not accidentally cause a NullReferenceException. This leads to ugly code, especially in a data-binding scenario, such as: &lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre class="csharpcode"&gt;&amp;lt;%# order == &lt;span class="kwrd"&gt;null&lt;/span&gt; ? &lt;span class="kwrd"&gt;null&lt;/span&gt; : order.Customer == &lt;span class="kwrd"&gt;null&lt;/span&gt; ? &lt;span class="kwrd"&gt;null&lt;/span&gt; : order.Customer.Name %&amp;gt;&lt;/pre&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;a title="Stackoverflow question about Deep Null Checking" href="http://stackoverflow.com/questions/2080647/deep-null-checking-is-there-a-better-way" target="ext"&gt;This question on StackOverflow&lt;/a&gt; asks about exactly that, how do we get rid of such explicit and repeated null checking ? It got me thinking, it must be possible to solve this using expression trees. It turns out, it is in fact possible, as I state in &lt;a title="StackOverflow answer" href="http://stackoverflow.com/questions/2080647/deep-null-checking-is-there-a-better-way/2081942#2081942" target="ext"&gt;my answer on StackOverflow&lt;/a&gt;. We can in fact build an extension methods, which looks at an expression tree, evaluates each part of it seperately, checks for null each time, and ultimately returns the correct value; or null if one of the expression parts where null. This is my implementation of such a method:&lt;/p&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 1: &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 2: &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 3: &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq.Expressions;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 4: &lt;/span&gt; &lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 5: &lt;/span&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; dr.IfNotNullOperator.PoC&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 6: &lt;/span&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 7: &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ObjectExtensions&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 8: &lt;/span&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 9: &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; TResult IfNotNull&amp;lt;TArg,TResult&amp;gt;(&lt;span class="kwrd"&gt;this&lt;/span&gt; TArg arg, Expression&amp;lt;Func&amp;lt;TArg,TResult&amp;gt;&amp;gt; expression)&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 10: &lt;/span&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 11: &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (expression == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 12: &lt;/span&gt;                &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ArgumentNullException(&lt;span class="str"&gt;"expression"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 13: &lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 14: &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (ReferenceEquals(arg, &lt;span class="kwrd"&gt;null&lt;/span&gt;))&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 15: &lt;/span&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;default&lt;/span&gt;(TResult);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 16: &lt;/span&gt; &lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 17: &lt;/span&gt;            var stack = &lt;span class="kwrd"&gt;new&lt;/span&gt; Stack&amp;lt;MemberExpression&amp;gt;();&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 18: &lt;/span&gt;            var expr = expression.Body &lt;span class="kwrd"&gt;as&lt;/span&gt; MemberExpression;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 19: &lt;/span&gt;            &lt;span class="kwrd"&gt;while&lt;/span&gt;(expr != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 20: &lt;/span&gt;            {&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 21: &lt;/span&gt;                stack.Push(expr);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 22: &lt;/span&gt;                expr = expr.Expression &lt;span class="kwrd"&gt;as&lt;/span&gt; MemberExpression;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 23: &lt;/span&gt;            } &lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 24: &lt;/span&gt; &lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 25: &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (stack.Count == 0 || !(stack.Peek().Expression &lt;span class="kwrd"&gt;is&lt;/span&gt; ParameterExpression))&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 26: &lt;/span&gt;                &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ApplicationException(String.Format(&lt;span class="str"&gt;"The expression '{0}' contains unsupported constructs."&lt;/span&gt;,&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 27: &lt;/span&gt;                                                             expression));&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 28: &lt;/span&gt;            &lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 29: &lt;/span&gt;            &lt;span class="kwrd"&gt;object&lt;/span&gt; a = arg;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 30: &lt;/span&gt;            &lt;span class="kwrd"&gt;while&lt;/span&gt;(stack.Count &amp;gt; 0)&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 31: &lt;/span&gt;            {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 32: &lt;/span&gt;                expr = stack.Pop();&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 33: &lt;/span&gt;                var p = expr.Expression &lt;span class="kwrd"&gt;as&lt;/span&gt; ParameterExpression;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 34: &lt;/span&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (p == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 35: &lt;/span&gt;                {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 36: &lt;/span&gt;                    p = Expression.Parameter(a.GetType(), &lt;span class="str"&gt;"x"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 37: &lt;/span&gt;                    expr = expr.Update(p);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 38: &lt;/span&gt;                }&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 39: &lt;/span&gt;                var lambda = Expression.Lambda(expr, p);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 40: &lt;/span&gt;                Delegate t = lambda.Compile();                &lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 41: &lt;/span&gt;                a = t.DynamicInvoke(a);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 42: &lt;/span&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (ReferenceEquals(a, &lt;span class="kwrd"&gt;null&lt;/span&gt;))&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 43: &lt;/span&gt;                    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;default&lt;/span&gt;(TResult);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 44: &lt;/span&gt;            }&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 45: &lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 46: &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; (TResult)a;            &lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 47: &lt;/span&gt;        }&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 48: &lt;/span&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 49: &lt;/span&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There are some caveats though, in the current version it will only work with simple member access, and it only works on .NET Framework 4, because it uses the MemberExpression.Update method, which is new in v4. &lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p style="MARGIN: 0cm 0cm 12pt; VERTICAL-ALIGN: baseline; background-origin: initial; background-clip: initial"&gt;&lt;span style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-ansi-language: EN-US"&gt;It works by examining the expression tree representing your expression, and evaluating the parts one after the other; each time checking that the result is not null. &lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p style="MARGIN: 0cm 0cm 12pt; VERTICAL-ALIGN: baseline; background-origin: initial; background-clip: initial"&gt;&lt;span style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-ansi-language: EN-US"&gt;I am sure this could be extended so that other expressions than MemberExpression is supported, and I might update it at a later point to support more complicated expressions. Consider this as proof-of-concept code, and please keep in mind that there will be a performance penalty by using it (which will probably not matter in many cases, but don't use it in a tight loop :-) ). I have not done any measurements on the performance yet, and I am also sure that one could make some optimizations to it. &lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-ansi-language: EN-US"&gt;Here is a zip containing the code as well as a few unit tests: &lt;/span&gt;&lt;span style="FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&lt;a title="Download (from MediaFire)" href="http://www.mediafire.com/?h2zktzd2mmd" target="ext"&gt;&lt;span style="mso-ansi-language: EN-US"&gt;&lt;span style="COLOR: #0000ff"&gt;IfNotNullExtension.zip&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-ansi-language: EN-US"&gt;. &lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="FONT-FAMILY: 'Tahoma','sans-serif'; mso-ansi-language: EN-US"&gt;What do you think about this approach to null checking ? Would you consider this extension method useful (provided that it performs adequately for the scenario) ? &lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 17 Jan 2010 18:47:00 UTC</pubDate>
    </item>
    <item>
      <title>Last day at TechEd</title>
      <link>/2009/11/Last-day-at-TechEd</link>
      <description>
		&lt;p&gt;It's friday, and TechEd is over for this time.&lt;/p&gt;
    &lt;p&gt;My first session on friday was about little-known secrets in Microsoft Silverlight 3. This was a really good session for advanced Silverlight development, and I took away many tricks - including the ability to download and use assemblies dynamically and asynchronously; and to use the OS client stack instead of the browser stack for network access.&lt;/p&gt;
    &lt;p&gt;Second session was about extending Visual Studio 2010's architecture modelling tools. This was a code-rich session, where we were walked through creating 3 extensions for the modelling tools. With VSIX packages, deployment of Visual Studio extensions are now much easier. The coding experience when creating extenions has also been made much nicer in the new verison of Visual Studio 2010. It is a no-frills experience, where you only need to work in the problem domain, and not jump through hoops to make Visual Studio do what you want. &lt;/p&gt;
    &lt;p&gt;The last session of this year's TechEd is about &lt;a title="Pex at Microsoft Research" href="http://research.microsoft.com/en-us/projects/Pex/" target="_blank"&gt;Pex&lt;/a&gt; and &lt;a title="Code Contracts at Microsoft Research" href="http://research.microsoft.com/en-us/projects/contracts/" target="_blank"&gt;Code Contracts&lt;/a&gt;. I am writing this while waiting for the session to be begin - it's a very interesting topic, and I might do a full length blog post about Pex and Code Contracts at a later time.&lt;/p&gt;
    &lt;p&gt;This has been a very educational and interesting week. I have learned about architecture and design, new tools and techniques. In general, the quality of the talks has been very high (there were a few misses, but it's been an overall good experience). The only problem has been to select the right session, when there were multiple interesting selections in the same time slot, which happened to me a lot. For instance, I never got to see a talk about the Concurrency Runtime (CCR), because there were always something more interesting on the menu. Now, I need to get home and get into the gym - it's been a week with good foods, eggs and bacon each morning at the hotel, so I need it :-) I Might be coming back next year !&lt;/p&gt;</description>
      <pubDate>Fri, 13 Nov 2009 09:56:00 UTC</pubDate>
    </item>
    <item>
      <title>Day Four at TechEd over</title>
      <link>/2009/11/Day-Four-at-TechEd-over</link>
      <description>
		&lt;p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"&gt;
      &lt;span style="mso-ansi-language: EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;TechEd is coming to an end, day four is now over. There are three sessions on friday, then it's over.&lt;/span&gt; &lt;/span&gt;
    &lt;/p&gt;
    &lt;p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"&gt;
      &lt;span style="mso-ansi-language: EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;I started the day with a session on C# 4.0 Dynamic: The why’s and hows. It was being done by Alex Turner, who is Program Manager for the C# compiler. This was a very interesting walk through why C# should have dynamic features, and why it has been designed as it is. There has gone a lot of design thought into the dynamic design, and I certainly think that the final design they’ve chosen is the right one. He demoed creating your own dynamic types from C# which can respond to any method call – very cool. I can certainly see some good use cases for the C# &lt;i style="mso-bidi-font-style: normal"&gt;dynamic&lt;/i&gt; keyword. &lt;p&gt;&lt;/p&gt;&lt;/span&gt;
        &lt;p&gt;
        &lt;/p&gt;
      &lt;/span&gt;
    &lt;/p&gt;
    &lt;p&gt;
    &lt;/p&gt;
    &lt;p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"&gt;
      &lt;span style="mso-ansi-language: EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;Next, I went to see a talk about Windows Communication Foundation: Developer’s Guide to Windows Communication Foundation, SOA and success. Interesting, and with some very good thoughts on interoperability. My most important take-away from that session, is that if you need to be interoperable, try to do REST. &lt;p&gt;&lt;/p&gt;&lt;/span&gt;
        &lt;p&gt;
        &lt;/p&gt;
      &lt;/span&gt;
    &lt;/p&gt;
    &lt;p&gt;
    &lt;/p&gt;
    &lt;p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"&gt;
      &lt;span style="mso-ansi-language: EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;In the afternoon, I went to see Tess Ferrandez present on ASP .NET post-mortem debugging (well, the techniques apply to any .NET process, I think, but it was presented towards ASP .NET). This is the kind of debugging you get to do when your process consumes too much memory, hangs, or explodes; in the production environment, without you being able to reproduce the issue locally. When this kind of debugging is needed, something is on fire, and you will get stress fixing it. But apart from that, I do find this kind of debugging challenging and kind-of-fun ;-) Tess demonstrated using WinDbg, SOS.dll (Son-of-Strike, someone please explain the name to me), Debug Diag and other tools. She demonstrated detecting a memory issue, a poor performance issue, and a crash issue using these tools. She also demonstrated doing these using Visual Studio 2010, with its new ability to open memory dumps, and do debugging on them. With this cool new feature, you can do almost everything you can do in a normal debug session, but in a memory dump, that you might have obtained from some production server. You can see the stack trace, the locals, and examine the value of objects. The only thing you cannot do, is run/step back/forward, of course, the dump is an image of the process at a specific time. Very neat is the Parallel Stacks feature, where Visual Studio will visualize the stack of each thread for you, which makes it easy to identify contention in your locking, as well as other thread sync issues. &lt;p&gt;&lt;/p&gt;&lt;/span&gt;
        &lt;p&gt;
        &lt;/p&gt;
      &lt;/span&gt;
    &lt;/p&gt;
    &lt;p&gt;
    &lt;/p&gt;
    &lt;p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"&gt;
      &lt;span style="mso-ansi-language: EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;Last session of the day was by Magnus Mårtensson. This was an architecture talk about design with dependency injection and ensuring extensibility. Very interesting.&lt;/span&gt; &lt;/span&gt;
    &lt;/p&gt;</description>
      <pubDate>Fri, 13 Nov 2009 09:50:00 UTC</pubDate>
    </item>
    <item>
      <title>Third day at TechEd</title>
      <link>/2009/11/Third-day-at-TechEd</link>
      <description>
		&lt;p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"&gt;
      &lt;span style="mso-ansi-language: EN-US" lang="EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;Once again, I attended some very interesting talks at TechEd. This mornings sessions was entitled “The daily Scrum”, about doing Scrum and agile development. This was mostly a Q&amp;amp;A session with answers to many of the practical problems one might encounter when trying to be agile.&lt;p&gt;&lt;/p&gt;&lt;/span&gt;
      &lt;/span&gt;
    &lt;/p&gt;
    &lt;p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"&gt;
      &lt;span style="mso-ansi-language: EN-US" lang="EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;Next, I had a real hard time deciding between staying on the agile track and attending the “Tools and Agile Teams” talk versus hearing Don Syme speak about F#. I chose the F# session, which I think was a good choice. Don is one of the primary architects behind F#, so it would have been a shame not to hear him speak about it. This talk really drove home some points about F#, and why it helps you do parallel programming, with immutability, the async language construct and Agents. Another good point is that F# should not be used for anything, and in a large application, Don suggested that only a small DLL might be written in F# - it should be used as a tool, where you needed. Don also showed some really impressing demos, using Direct3D from F#.&lt;p&gt;&lt;/p&gt;&lt;/span&gt;
      &lt;/span&gt;
    &lt;/p&gt;
    &lt;p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"&gt;
      &lt;span style="mso-ansi-language: EN-US" lang="EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;After lunch, I attended Roy Osherove’s talk about unit testing. His main points where to write maintainable, consistent and readable unit tests, and proceeded to show this can be done. He suggested using test reviews in order to get started writing good unit tests, which I think is a very good idea. Very insightful talk.&lt;p&gt;&lt;/p&gt;&lt;/span&gt;
      &lt;/span&gt;
    &lt;/p&gt;
    &lt;p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"&gt;
      &lt;span style="mso-ansi-language: EN-US" lang="EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;The last session of today was about cloud computing: “&lt;/span&gt;
      &lt;/span&gt;
      &lt;span class="apple-style-span"&gt;
        &lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Arial','sans-serif'; COLOR: black; FONT-SIZE: 8.5pt; mso-ansi-language: EN-US" lang="EN-US"&gt;Deep Dive into Developing Line-of-Business Applications Running in the Cloud&lt;/span&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;”. &lt;/span&gt;
      &lt;/span&gt;
      &lt;span style="mso-ansi-language: EN-US" lang="EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;I don’t think this was a good session. There was too much demoing of an app in the cloud, and too little talk about the actual architecture behind it. Also, the presenters neglected to do any introduction to the Azure tools, I guess they expected everyone attending to know about those in advance.&lt;p&gt;&lt;/p&gt;&lt;/span&gt;
      &lt;/span&gt;
    &lt;/p&gt;</description>
      <pubDate>Wed, 11 Nov 2009 18:07:00 UTC</pubDate>
    </item>
    <item>
      <title>Day Two At TechEd Europe</title>
      <link>/2009/11/Day-Two-At-TechEd-Europe</link>
      <description>
		&lt;p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"&gt;
      &lt;span style="mso-ansi-language: EN-US" lang="EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;Today started off fresh with 2 Sharepoint sessions The first one was an introduction to Sharepoint 2010 for developers, and while I haven’t done any development on Sharepoint before, based on the feedback, it will be tons easier to do Sharepoint development with 2010. The second session on Sharepoint was somewhat relevant and somewhat a&lt;span style="mso-spacerun: yes"&gt;  &lt;/span&gt;miss. While it did provide some good information, there was not really anything new, if you had attended the first session.&lt;p&gt;&lt;/p&gt;&lt;/span&gt;
      &lt;/span&gt;
    &lt;/p&gt;
    &lt;p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"&gt;
      &lt;span style="mso-ansi-language: EN-US" lang="EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;During lunch, I had been invited to a lunch session by Microsoft Denmark on IIS 7.5. The speaker was&lt;span style="mso-spacerun: yes"&gt;  &lt;/span&gt;a real expert on the subject, Bernhard Frank. Very interesting and good&lt;span style="mso-spacerun: yes"&gt;  &lt;/span&gt;food, but had to cut the session short in order to make it to the next session.&lt;p&gt;&lt;/p&gt;&lt;/span&gt;
      &lt;/span&gt;
    &lt;/p&gt;
    &lt;p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"&gt;
      &lt;span style="mso-ansi-language: EN-US" lang="EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;Next was a presentation by Brian Harry about TFS 2010 and its new version control features. There are some real goodies coming ,, in 2010, and Brian demonstrated better branching and branch visualization, support for rollback and improved labeling. Very nice, and something I can really see the need for in my own organization. &lt;p&gt;&lt;/p&gt;&lt;/span&gt;
      &lt;/span&gt;
    &lt;/p&gt;
    &lt;p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"&gt;
      &lt;span style="mso-ansi-language: EN-US" lang="EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;I also attended a session on software architecture by Ralf Westphal. He discussed architecture at a high level, and you should not view the architecture as UML class diagram, layered architechture diagram or something like that. Instead he advocated functional&lt;span style="mso-spacerun: yes"&gt;  &lt;/span&gt;building blocks, or functional units as he called it; which recursively consists of yet another set of functional units. This way, you get a hierarchy of functional units from the one application, through synchronous components till methods in a class. While surely one of the most abstract talks today, I took some very good points with me from the talk.&lt;p&gt;&lt;/p&gt;&lt;/span&gt;
      &lt;/span&gt;
    &lt;/p&gt;
    &lt;p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"&gt;
      &lt;span style="mso-ansi-language: EN-US" lang="EN-US"&gt;
        &lt;span style="FONT-FAMILY: Calibri"&gt;Lastly today, there was an ASP .NET MVC2: “What’s new” session that I attended. It really competed with the “Pumping Iron” session (about IronRuby/Python), but as it turns out, that session was overbooked, so I made the right choice. There is some really great improvements in MVC2, which boils down to improving productivity on the framework. This means support for partial renderings based on invoking of controllers, and templated views. A cool demo was demonstrating the validation features, where you can define your validation rules in the model (as annotations out-of-the-box, but it’s extensible, so you can store your rules wherever you like). I think MVC2 might just be the release that is mature enough to be tried out on a real project – I am sure our frontend developers will love it.&lt;p&gt;&lt;/p&gt;&lt;/span&gt;
      &lt;/span&gt;
    &lt;/p&gt;</description>
      <pubDate>Tue, 10 Nov 2009 22:47:00 UTC</pubDate>
    </item>
    <item>
      <title>Got a Twitter account</title>
      <link>/2009/11/Got-a-Twitter-account</link>
      <description>Oh, BTW, I got a twitter account. Follow me on &lt;a href="http://twitter.com/dennisriis"&gt;http://twitter.com/dennisriis&lt;/a&gt;, if interested.</description>
      <pubDate>Mon, 09 Nov 2009 23:25:00 UTC</pubDate>
    </item>
  </channel>
</rss>