<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>2LeggedSpider</title>
	
	<link>http://2leggedspider.wordpress.com</link>
	<description>Thoughts on Web development and more...</description>
	<lastBuildDate>Wed, 15 May 2013 05:07:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain="2leggedspider.wordpress.com" port="80" path="/?rsscloud=notify" registerProcedure="" protocol="http-post" />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>2LeggedSpider</title>
		<link>http://2leggedspider.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://2leggedspider.wordpress.com/osd.xml" title="2LeggedSpider" />
	
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/2leggedspider" /><feedburner:info uri="2leggedspider" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://2leggedspider.wordpress.com/?pushpress=hub" /><feedburner:emailServiceId>2leggedspider</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>ASP.NET Web API Video Series</title>
		<link>http://feedproxy.google.com/~r/2leggedspider/~3/QSTbjjT5bIk/</link>
		<comments>http://2leggedspider.wordpress.com/2012/03/06/asp-net-web-api-video-series/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 22:11:45 +0000</pubDate>
		<dc:creator>Sumit Thomas</dc:creator>
				<category><![CDATA[Daily Links]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[videos]]></category>
		<category><![CDATA[webapi]]></category>

		<guid isPermaLink="false">http://2leggedspider.wordpress.com/2012/03/06/asp-net-web-api-video-series/</guid>
		<description><![CDATA[ASP.NET Web API, Part 1: Your First Web API ASP.NET Web API, Part 2: Getting Data ASP.NET Web API, Part 3: Delete and Update ASP.NET Web API, Part 4: Paging and Querying ASP.NET Web API, Part 5: Custom Validation ASP.NET Web API, Part 6: Authorization Tagged: ASP.NET, videos, webapi<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=591&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<ul>
<li><a href="http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/video-your-first-web-api">ASP.NET Web API, Part 1: Your First Web API</a></li>
<li><a href="http://www.asp.net/web-api/overview/web-api-routing-and-actions/video-getting-data">ASP.NET Web API, Part 2: Getting Data</a></li>
<li><a href="http://www.asp.net/web-api/overview/web-api-routing-and-actions/video-delete-and-create">ASP.NET Web API, Part 3: Delete and Update</a></li>
<li><a href="http://www.asp.net/web-api/overview/web-api-routing-and-actions/video-paging-and-querying">ASP.NET Web API, Part 4: Paging and Querying</a></li>
<li><a href="http://www.asp.net/web-api/overview/web-api-routing-and-actions/video-custom-validation">ASP.NET Web API, Part 5: Custom Validation</a></li>
<li><a href="http://www.asp.net/web-api/overview/web-api-routing-and-actions/video-authorization">ASP.NET Web API, Part 6: Authorization</a></li>
</ul>
<br /> Tagged: <a href='http://2leggedspider.wordpress.com/tag/aspnet/'>ASP.NET</a>, <a href='http://2leggedspider.wordpress.com/tag/videos/'>videos</a>, <a href='http://2leggedspider.wordpress.com/tag/webapi/'>webapi</a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=591&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/2leggedspider/~4/QSTbjjT5bIk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://2leggedspider.wordpress.com/2012/03/06/asp-net-web-api-video-series/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3f32eca38c5ea5d1d86681bc09214cf2?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">SavageKid</media:title>
		</media:content>
	<feedburner:origLink>http://2leggedspider.wordpress.com/2012/03/06/asp-net-web-api-video-series/</feedburner:origLink></item>
		<item>
		<title>Coffee break</title>
		<link>http://feedproxy.google.com/~r/2leggedspider/~3/FXgrDEaKRYk/</link>
		<comments>http://2leggedspider.wordpress.com/2012/03/03/coffee-break-15/#comments</comments>
		<pubDate>Fri, 02 Mar 2012 22:18:43 +0000</pubDate>
		<dc:creator>Sumit Thomas</dc:creator>
				<category><![CDATA[Coffee Break]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[coffee break]]></category>
		<category><![CDATA[windows 8]]></category>

		<guid isPermaLink="false">http://2leggedspider.wordpress.com/?p=580</guid>
		<description><![CDATA[How To Guide to Installing and Booting Windows 8 Consumer Preview off a VHD (Virtual Hard Disk) : Scott Hanselman runs you through the steps involved in installing and booting Windows 8 Consumer Preview off a VHD. As always, very informative Develop Hybrid Native and Mobile Web Apps : Shane Church discusses how we can develop [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=580&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<ul>
<li><a href="http://www.hanselman.com/blog/HowToGuideToInstallingAndBootingWindows8ConsumerPreviewOffAVHDVirtualHardDisk.aspx?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+ScottHanselman+%28Scott+Hanselman+-+ComputerZen.com%29">How To Guide to Installing and Booting Windows 8 Consumer Preview off a VHD (Virtual Hard Disk)</a> : Scott Hanselman runs you through the steps involved in installing and booting Windows 8 Consumer Preview off a VHD. As always, very informative</li>
<li><a href="http://msdn.microsoft.com/en-us/magazine/hh852592.aspx">Develop Hybrid Native and Mobile Web Apps</a> : Shane Church discusses how we can develop mobile web applications that takes advantage of native application shell to provide the best user experience</li>
<li><a href="http://msdn.microsoft.com/en-us/magazine/hh852588.aspx" target="_blank">Entity Framework Code First and DbContext FAQs</a> : Julie Lerman addresses some of the frequent asked questions on Code First and DbContext in Entity Framework 4.2</li>
<li><a href="http://www.dnrtv.com/default.aspx?showNum=63" target="_blank">Jean-Paul Boodhoo on Demystifying Design Patterns Part 1</a> : An old video but still informative, Jean-Paul Boodhoo talks about Factory and Singleton patterns in depth</li>
<li><a href="http://venturebeat.com/2012/03/01/listen-up-google-heres-what-windows-8-can-teach-you-about-tablets/" target="_blank">Listen up, Google: Here’s what Windows 8 can teach you about tablets</a> : Devindra Hardawar says &#8220;Windows 8 is certain to make a huge splash with consumers &#8212; not just because it&#8217;s the next version of Windows, but because Microsoft has finally managed to crack the code for putting Windows on tablets&#8221;. Read more&#8230;</li>
</ul>
<br /> Tagged: <a href='http://2leggedspider.wordpress.com/tag/aspnet/'>ASP.NET</a>, <a href='http://2leggedspider.wordpress.com/tag/coffee-break-2/'>coffee break</a>, <a href='http://2leggedspider.wordpress.com/tag/windows-8/'>windows 8</a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=580&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/2leggedspider/~4/FXgrDEaKRYk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://2leggedspider.wordpress.com/2012/03/03/coffee-break-15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3f32eca38c5ea5d1d86681bc09214cf2?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">SavageKid</media:title>
		</media:content>
	<feedburner:origLink>http://2leggedspider.wordpress.com/2012/03/03/coffee-break-15/</feedburner:origLink></item>
		<item>
		<title>Coffee break</title>
		<link>http://feedproxy.google.com/~r/2leggedspider/~3/Kcsj_cvJtmE/</link>
		<comments>http://2leggedspider.wordpress.com/2012/03/02/coffee-break/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 20:25:12 +0000</pubDate>
		<dc:creator>Sumit Thomas</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Coffee Break]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://2leggedspider.wordpress.com/?p=552</guid>
		<description><![CDATA[Using MS WebAPI to add API Support to Your Existing ASP.NET MVC Web Applications : Sumit Maitra talks about how to use the newly launched WebAPI in an existing MVC 3 application by upgrading it to ASP.NET MVC 4 and extending it to provide http services using the WebAPI Compare Visual Studio 11 Beta editions : Here is [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=552&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<ul>
<li><a title="Using MS WebAPI to add API Support to Your Existing ASP.NET MVC Web Applications" href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=788" target="_blank">Using MS WebAPI to add API Support to Your Existing ASP.NET MVC Web Applications</a> : Sumit Maitra talks about how to use the newly launched WebAPI in an existing MVC 3 application by upgrading it to ASP.NET MVC 4 and extending it to provide http services using the WebAPI</li>
<li><a href="http://www.microsoft.com/visualstudio/11/en-us/products/compare" target="_blank">Compare Visual Studio 11 Beta editions</a> : Here is a quick comparison of the new Visual Studio 11 beta editions</li>
<li><a href="http://blogs.msdn.com/b/somasegar/archive/2012/02/29/visual-studio-11-beta-and-net-4-5-beta-available-now.aspx" target="_blank">Visual Studio 11 Beta and .NET 4.5 Beta &#8211; Available now!</a> : Somasegar announces the availability of Visual Studio 11 Beta and .NET 4.5 Beta versions for download.  Do check the links highlighting some of the innovations that have gone in to building Visual Studio 11 Developer Preview release</li>
<li><a href="http://dotnetslackers.com/articles/aspnet/Introduction-to-jQuery-Mobile.aspx" target="_blank">Introduction to jQuery mobile</a> : Brian Mains discusses the jQuery Mobile framework for developing user interfaces for mobile devices</li>
<li><a href="http://www.hanselman.com/blog/OneASPNETMakingJSONWebAPIsWithASPNETMVC4BetaAndASPNETWebAPI.aspx" target="_blank">One ASP.NET &#8211; Making JSON Web APIs with ASP.NET MVC 4 Beta and ASP.NET Web API</a> : Scott Hanselman talks about the improvements in MVC 4, about Web API and how it fits in to One ASP.NET</li>
</ul>
<br /> Tagged: <a href='http://2leggedspider.wordpress.com/tag/aspnet/'>ASP.NET</a>, <a href='http://2leggedspider.wordpress.com/tag/jquery/'>jquery</a>, <a href='http://2leggedspider.wordpress.com/tag/technology/'>technology</a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=552&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/2leggedspider/~4/Kcsj_cvJtmE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://2leggedspider.wordpress.com/2012/03/02/coffee-break/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3f32eca38c5ea5d1d86681bc09214cf2?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">SavageKid</media:title>
		</media:content>
	<feedburner:origLink>http://2leggedspider.wordpress.com/2012/03/02/coffee-break/</feedburner:origLink></item>
		<item>
		<title>Getting specific with the Specification Pattern</title>
		<link>http://feedproxy.google.com/~r/2leggedspider/~3/LDNUzYhsHFs/</link>
		<comments>http://2leggedspider.wordpress.com/2011/03/23/getting-specific-with-the-specification-pattern/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 11:25:21 +0000</pubDate>
		<dc:creator>Sumit Thomas</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[patterns]]></category>

		<guid isPermaLink="false">http://2leggedspider.wordpress.com/?p=503</guid>
		<description><![CDATA[The idea of Specification pattern according to Martin Fowler is to separate the statement of how to match a candidate, from the candidate object that it is matched against. As well as its usefulness in selection, it is also valuable for validation and for building to order. In simple terms it means this pattern helps [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=503&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The <a href="http://martinfowler.com/apsupp/spec.pdf">idea</a> of Specification pattern according to Martin Fowler is to separate the statement of how to match a candidate, from the candidate object that it is matched against. As well as its usefulness in selection, it is also valuable for validation and for building to order.</p>
<p>In simple terms it means this pattern helps us to check if an object satisfies certain criteria. Well, we do that all the time in our code don&#8217;t we? For instance, we check if the data in an object that we send to a web service or database is properly validated against a business rule. We check for certain conditions on an object&#8217;s property to fetch subset of objects from a collection using say LINQ etc etc. Since we already do these things, why do we need a separate pattern to do the same?</p>
<p>Well the biggest advantage of Specification pattern is that we can create compartments of criteria definitions and check them against an object wherever the need arises. We then have the flexibility to change the criteria definitions in one single place as per the business requirement instead of changing it all the places where such criteria would had been used, if we didn&#8217;t use specification pattern. OK enough theory, lets see how we can implement the Specification pattern to understand it better.</p>
<p>We&#8217;ll start by creating the Core framework for the Specification. Lets create an Interface ISpecification with the following definition</p>
<pre class="brush: csharp; title: ; notranslate">
public interface ISpecification&lt;T&gt;
{
     bool IsSatisfiedBy(T t);
}
</pre>
<p>Now as I mentioned earlier, we can check if an object satisfies a certain condition or a set of conditions. In order to make it easy for us we&#8217;ll create classes which will help us perform the logical And, Or and Not operations on an object with the available suggestions.</p>
<pre class="brush: csharp; title: ; notranslate">
    public class AndSpecification&lt;T&gt; : ISpecification&lt;T&gt;
    {
        private readonly ISpecification&lt;T&gt; spec1;
        private readonly ISpecification&lt;T&gt; spec2;
        public AndSpecification(ISpecification&lt;T&gt; s1, ISpecification&lt;T&gt; s2)
        {
            spec1 = s1;
            spec2 = s2;
        }

        public bool IsSatisfiedBy(T t)
        {
            return spec1.IsSatisfiedBy(t) &amp;&amp; spec2.IsSatisfiedBy(t);
        }

    }

    public class OrSpecification&lt;T&gt; : ISpecification&lt;T&gt;
    {
        private readonly ISpecification&lt;T&gt; spec1;
        private readonly ISpecification&lt;T&gt; spec2;
        public OrSpecification(ISpecification&lt;T&gt; s1, ISpecification&lt;T&gt; s2)
        {
            spec1 = s1;
            spec2 = s2;
        }

        public bool IsSatisfiedBy(T t)
        {
            return spec1.IsSatisfiedBy(t) || spec2.IsSatisfiedBy(t);
        }
    }

    public class NotSpecification&lt;T&gt; : ISpecification&lt;T&gt;
    {
        private readonly ISpecification&lt;T&gt; spec;
        public NotSpecification(ISpecification&lt;T&gt; spec)
        {
            this.spec = spec;
        }

        public bool IsSatisfiedBy(T t)
        {
            return !spec.IsSatisfiedBy(t);
        }
    }
</pre>
<p>Next we will create extension methods that will help us to chain together required specifications.</p>
<pre class="brush: csharp; title: ; notranslate">
    public static class SpecExtensions
    {
        public static ISpecification&lt;T&gt; And&lt;T&gt;(this ISpecification&lt;T&gt; s1, ISpecification&lt;T&gt; s2)
        {
            return new AndSpecification&lt;T&gt;(s1, s2);
        }
        public static ISpecification&lt;T&gt; Or&lt;T&gt;(this ISpecification&lt;T&gt; s1, ISpecification&lt;T&gt; s2)
        {
            return new OrSpecification&lt;T&gt;(s1, s2);
        }
        public static ISpecification&lt;T&gt; Not&lt;T&gt;(this ISpecification&lt;T&gt; s)
        {
            return new NotSpecification&lt;T&gt;(s);
        }
    }
</pre>
<p>That pretty much forms the core implementation of Specification pattern. Now lets get in to the fun part where we will put the specification pattern in use.</p>
<p>Lets assume that you are creating a module for fictional employee management application to determine the qualification of employees in order to promote them to managers. Lets start by creating a Employee class as follows</p>
<pre class="brush: csharp; title: ; notranslate">
    public class Employee
    {
        public int EmployeeId { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int TotalExperience { get; set; }
        public ExcelCompetency ExcelCompetency { get; set; }
        public bool PotentialManager
        {
            get
            {
                if (ExcelCompetency == Domain.ExcelCompetency.High || ExcelCompetency == Domain.ExcelCompetency.Medium)
                    return true;

                return false;
            }
        }
    }
</pre>
<p>Here ExcelCompetency is an enum with values High, Medium and Low. Assume that the specification provided to you is that only Employees with High or Medium competency in Excel can become Managers. The property PotentialManager checks this condition and returns a boolean based on the value assigned for ExcelCompetency.</p>
<p>Though the property PotentialManager would help us in fetching a subset of employees qualified to be a manager from a list of employees, the actual condition we used inside this property might be used elsewhere in our application. In such cases, if the company decides later that employees with only High ExcelCompetency can become managers then we would have to change the condition wherever it is implemented. That is not ideal. This is where Specification pattern could be used.</p>
<p>Lets start by creating our own implementation of Specification framework.</p>
<pre class="brush: csharp; title: ; notranslate">
    public class PotentialManagerSpecification : ISpecification&lt;Employee&gt;
    {
        public bool IsSatisfiedBy(Employee employee)
        {
            if (employee.ExcelCompetency == ExcelCompetency.High || employee.ExcelCompetency == ExcelCompetency.Medium)
                return true;
            return false;
        }
    }
</pre>
<p>Now our PotentialManager property could be changed to&#8230;</p>
<pre class="brush: csharp; title: ; notranslate">
        public bool PotentialManager
        {
            get
            {
                var  potentialManagerSpec = new PotentialManagerSpecification();
                if (potentialManagerSpec.IsSatisfiedBy(this))
                    return true;
                return false;
            }
        }
</pre>
<p>Now the condition for satisfying a requirement will lie independent of the entity object and can be changed anytime without touching the entity.</p>
<p>Now lets assume that the management has laid down a condition that managers should not only have High Excel competency but also should have more than 10 years of experience. To satisfy this condition lets create another specification ManagerRequiredExperienceSpecification</p>
<pre class="brush: csharp; title: ; notranslate">
    public class ManagerRequiredExperienceSpecification : ISpecification&lt;Employee&gt;
    {
        public bool IsSatisfiedBy(Employee employee)
        {
            if (employee.TotalExperience &gt; 10)
                return true;
            return false;
        }
    }
</pre>
<p>We&#8217;ll create a test method to test these specifications</p>
<pre class="brush: csharp; title: ; notranslate">
[TestMethod]
public void ManagerSelection_Test()
{
Employee abc = new Employee(){ FirstName=&quot;ABC&quot;, ExcelCompetency = ExcelCompetency.Medium, TotalExperience = 12};
Employee def = new Employee(){ FirstName = &quot;DEF&quot;, ExcelCompetency = ExcelCompetency.High, TotalExperience = 11};
Employee qrs = new Employee(){ FirstName = &quot;QRS&quot;, ExcelCompetency = ExcelCompetency.High, TotalExperience = 8};
Employee xyz = new Employee(){FirstName = &quot;XYZ&quot;, ExcelCompetency = ExcelCompetency.Low, TotalExperience = 10};

IList employees = new List()
{
  abc, def, qrs, xyz
};

PotentialManagerSpecification managerSpec = new PotentialManagerSpecification();
ManagerRequiredExperienceSpecification experienceSpec = new ManagerRequiredExperienceSpecification();

foreach(Employee e in employees){
    System.Diagnostics.Debug.WriteLine(
      &quot;{0} is {1} to be a Manager&quot;,
       e.FirstName,
       managerSpec.And(experienceSpec).IsSatisfiedBy(e) ? &quot;qualified&quot; : &quot;not qualified&quot;
       );
}
}
</pre>
<p>If you run the above test, your Debug trace will show the following output</p>
<p><em>ABC is qualified to be a Manager<br />
DEF is qualified to be a Manager<br />
QRS is not qualified to be a Manager<br />
XYZ is not qualified to be a Manager</em></p>
<p>You can see in the line <strong>managerSpec.And(experienceSpec).IsSatisfiedBy(e)</strong> how we have used the extension method &#8216;And&#8217;.</p>
<p>Based on the requirement we can use the extension methods as follows.</p>
<ul>
<li>managerSpec.And(experienceSpec).IsSatisfiedBy(e) -&gt; Employee satisfies both PotentialManagerSpecification and ManagerRequiredExperienceSpecification</li>
<li>managerSpec.Or(experienceSpec).IsSatisfiedBy(e) -&gt; Employee satisfies either PotentialManagerSpecification or ManagerRequiredExperienceSpecification</li>
<li>managerSpec.And(experienceSpec.Not()).IsSatisfiedBy(e) -&gt; Employee satisfies PotentialManagerSpecification but not ManagerRequiredExperienceSpecification</li>
</ul>
<p>As you can see the possibilities are limitless. If you want to create a new specification which handles both PotentialManagerSpecification and ManagerRequiredExperienceSpecification then we can also do so as follows</p>
<pre class="brush: csharp; title: ; notranslate">
    public class ManagerSelectionSpecification : ISpecification&lt;Employee&gt;
    {
        public bool IsSatisfiedBy(Employee employee)
        {
            PotentialManagerSpecification managerSpec = new PotentialManagerSpecification();
            ManagerRequiredExperienceSpecification experienceSpec = new ManagerRequiredExperienceSpecification();

            if (managerSpec.And(experienceSpec).IsSatisfiedBy(employee))
                return true;

            return false;
        }
    }
</pre>
<p>We can also use specifications to perform validation before saving information in database for instance</p>
<pre class="brush: csharp; title: ; notranslate">
var managerSelectionSpec = new ManagerSelectionSpecification();
if(managerSelectionSpec.IsSatisfiedBy(employee)
{
      PromoteToManager();
}
</pre>
<p>Or in LINQ as follows</p>
<pre class="brush: csharp; title: ; notranslate">
 var managers = from e in employees
                           where managerSelectionSpec.IsSatisfiedBy(e)
                           select e;
</pre>
<p>Pretty neat isn&#8217;t it? I hope you found it useful as I did.</p>
<p>Some useful links&#8230;</p>
<p><a href="http://martinfowler.com/apsupp/spec.pdf">Specifications by by Eric Evans and Martin Fowler</a></p>
<p><a href="http://kitchaiyong.wordpress.com/2009/10/10/repository-specification-unit-of-work-persistence-ignorance-poco-with-microsoft-entityframework-4-0-part-2/">Repository, Specification, Unit of Work, Persistence Ignorance POCO with Microsoft ADO.NET Entity Framework 4.0 Beta 2</a></p>
<p><a href="http://www.dimecasts.net/Content/WatchEpisode/139">Learning the Specification Pattern</a></p>
<br />  <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=503&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/2leggedspider/~4/LDNUzYhsHFs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://2leggedspider.wordpress.com/2011/03/23/getting-specific-with-the-specification-pattern/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3f32eca38c5ea5d1d86681bc09214cf2?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">SavageKid</media:title>
		</media:content>
	<feedburner:origLink>http://2leggedspider.wordpress.com/2011/03/23/getting-specific-with-the-specification-pattern/</feedburner:origLink></item>
		<item>
		<title>Visual Studio color schemes – Its time for a makeover</title>
		<link>http://feedproxy.google.com/~r/2leggedspider/~3/-ofbwIeJVh0/</link>
		<comments>http://2leggedspider.wordpress.com/2011/03/23/visual-studio-color-schemes-its-time-for-a-makeover/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 07:30:32 +0000</pubDate>
		<dc:creator>Sumit Thomas</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://2leggedspider.wordpress.com/?p=512</guid>
		<description><![CDATA[http://studiostyl.es/ is a great website where you can browse for hundreds of color schemes to change the background and text colors of your Visual Studio IDE. It works for both Visual Studio 2008 and 2010. You can also create and submit your own scheme or download and rate schemes submitted by others. Once you have [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=512&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://studiostyl.es/">http://studiostyl.es/</a> is a great website where you can browse for hundreds of color schemes to change the background and text colors of your Visual Studio IDE. It works for both Visual Studio 2008 and 2010. You can also create and submit your own scheme or download and rate schemes submitted by others.</p>
<p><img class="aligncenter size-full wp-image-514" title="Visual Studio Color Schemes - http://studiostyl.es/" src="http://2leggedspider.files.wordpress.com/2011/03/shemes.png?w=720&#038;h=450" alt="" width="720" height="450" /></p>
<p>Once you have picked your&nbsp;favorite scheme, download it to your Visual Studio settings folder&nbsp;C:\Users\[user_name]\Documents\visual studio 2010\settings</p>
<p>To apply the scheme go to Tools -&gt; Import and Export Settings menu and follow these steps</p>
<p><img class="aligncenter size-full wp-image-515" title="importsettingdialog" src="http://2leggedspider.files.wordpress.com/2011/03/importsettingdialog.png?w=720" alt=""   /></p>
<p><img class="aligncenter size-full wp-image-517" title="importsettingdialog_next" src="http://2leggedspider.files.wordpress.com/2011/03/importsettingdialog_next.png?w=720" alt=""   /></p>
<p><img class="aligncenter size-full wp-image-516" title="importsettingdialog_choose" src="http://2leggedspider.files.wordpress.com/2011/03/importsettingdialog_choose.png?w=720" alt=""   /></p>
<p>Once you complete the steps, you will see a brand new color scheme applied to your Visual Studio text editor. </p>
<p><img class="aligncenter size-full wp-image-522" title="applied_scheme" src="http://2leggedspider.files.wordpress.com/2011/03/applied_scheme.png?w=720&#038;h=424" alt="" width="720" height="424" /></p>
<p>Now don&#8217;t be surprised if you find a fellow developer&#8217;s Visual Studio with a Barbie girl scheme <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<br />  <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=512&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/2leggedspider/~4/-ofbwIeJVh0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://2leggedspider.wordpress.com/2011/03/23/visual-studio-color-schemes-its-time-for-a-makeover/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3f32eca38c5ea5d1d86681bc09214cf2?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">SavageKid</media:title>
		</media:content>

		<media:content url="http://2leggedspider.files.wordpress.com/2011/03/shemes.png" medium="image">
			<media:title type="html">Visual Studio Color Schemes - http://studiostyl.es/</media:title>
		</media:content>

		<media:content url="http://2leggedspider.files.wordpress.com/2011/03/importsettingdialog.png" medium="image">
			<media:title type="html">importsettingdialog</media:title>
		</media:content>

		<media:content url="http://2leggedspider.files.wordpress.com/2011/03/importsettingdialog_next.png" medium="image">
			<media:title type="html">importsettingdialog_next</media:title>
		</media:content>

		<media:content url="http://2leggedspider.files.wordpress.com/2011/03/importsettingdialog_choose.png" medium="image">
			<media:title type="html">importsettingdialog_choose</media:title>
		</media:content>

		<media:content url="http://2leggedspider.files.wordpress.com/2011/03/applied_scheme.png" medium="image">
			<media:title type="html">applied_scheme</media:title>
		</media:content>
	<feedburner:origLink>http://2leggedspider.wordpress.com/2011/03/23/visual-studio-color-schemes-its-time-for-a-makeover/</feedburner:origLink></item>
		<item>
		<title>StyleCop 4.5 Beta is out!</title>
		<link>http://feedproxy.google.com/~r/2leggedspider/~3/O3ahb_oRfA8/</link>
		<comments>http://2leggedspider.wordpress.com/2011/03/21/stylecop-4-5-beta-is-out/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 06:40:06 +0000</pubDate>
		<dc:creator>Sumit Thomas</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://2leggedspider.wordpress.com/?p=537</guid>
		<description><![CDATA[You can download it @ http://stylecop.codeplex.com/releases/view/62209 If you are not aware of StyleCop, it is an open source static code analysis tool from Microsoft which helps developers analyse their C# code for conformance to StyleCop recommended coding styles and it works at the source code level. For more information on this community driven project visit [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=537&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>You can download it @ <a href="http://stylecop.codeplex.com/releases/view/62209">http://stylecop.codeplex.com/releases/view/62209</a></p>
<p>If you are not aware of StyleCop, it is an open source static code analysis tool from Microsoft which helps developers analyse their C# code for conformance to StyleCop recommended coding styles and it works at the source code level.</p>
<p>For more information on this community driven project visit <a href="http://stylecop.codeplex.com/">http://stylecop.codeplex.com/</a></p>
<br />  <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=537&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/2leggedspider/~4/O3ahb_oRfA8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://2leggedspider.wordpress.com/2011/03/21/stylecop-4-5-beta-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3f32eca38c5ea5d1d86681bc09214cf2?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">SavageKid</media:title>
		</media:content>
	<feedburner:origLink>http://2leggedspider.wordpress.com/2011/03/21/stylecop-4-5-beta-is-out/</feedburner:origLink></item>
		<item>
		<title>links for 2010-01-11</title>
		<link>http://feedproxy.google.com/~r/2leggedspider/~3/nQ4K7l-IWFY/</link>
		<comments>http://2leggedspider.wordpress.com/2010/01/11/links-for-2010-01-11/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 12:03:12 +0000</pubDate>
		<dc:creator>Sumit Thomas</dc:creator>
				<category><![CDATA[Daily Links]]></category>

		<guid isPermaLink="false">http://2leggedspider.wordpress.com/2010/01/11/links-for-2010-01-11/</guid>
		<description><![CDATA[Coda Bubble jQuery Plugin (tags: jquery, plugin,) Some Useful JavaScript &#38; jQuery Snippets &#124; Codrops (tags: jquery,) Smart Columns w/ CSS &#38; jQuery (tags: jquery, css) jQuery File Tree Demo (tags: jquery,) jQuery Masonry (tags: jquery, plugin,) ASP.NET MVC Validation using IDataErrorInfo with DefaultModelBinder (tags: aspnetmvc, validation,) Coding Instinct: Breadcrumb menu using JQuery and ASP.NET [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=501&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="http://www.myjquery.co.uk/docs/x/plugins/coda_bubble/coda_bubble.php">Coda Bubble jQuery Plugin</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/jquery%2C">jquery,</a> <a href="http://delicious.com/savagekid/plugin%2C">plugin,</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://tympanus.net/codrops/2010/01/05/some-useful-javascript-jquery-snippets/">Some Useful JavaScript &amp; jQuery Snippets | Codrops</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/jquery%2C">jquery,</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://www.sohtanaka.com/web-design/smart-columns-w-css-jquery/">Smart Columns w/ CSS &amp; jQuery</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/jquery%2C">jquery,</a> <a href="http://delicious.com/savagekid/css">css</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://labs.abeautifulsite.net/projects/js/jquery/fileTree/demo/">jQuery File Tree Demo</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/jquery%2C">jquery,</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://desandro.com/resources/jquery-masonry">jQuery Masonry</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/jquery%2C">jquery,</a> <a href="http://delicious.com/savagekid/plugin%2C">plugin,</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://davidhayden.com/blog/dave/archive/2009/05/11/ASPNETMVCValidationIDataErrorInfoDefaultModelBinder.aspx">ASP.NET MVC Validation using IDataErrorInfo with DefaultModelBinder</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/aspnetmvc%2C">aspnetmvc,</a> <a href="http://delicious.com/savagekid/validation%2C">validation,</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://www.codinginstinct.com/2008/10/breadcrum-menu-using-jquery-and-aspnet.html">Coding Instinct: Breadcrumb menu using JQuery and ASP.NET MVC</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/jquery%2C">jquery,</a> <a href="http://delicious.com/savagekid/aspnetmvc">aspnetmvc</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://bradwilson.typepad.com/blog/2009/04/dataannotations-and-aspnet-mvc.html">Brad Wilson: DataAnnotations and ASP.NET MVC</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/aspnetmvc">aspnetmvc</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://odetocode.com/Blogs/scott/archive/2009/04/27/6-tips-for-asp-net-mvc-model-binding.aspx">6 Tips for ASP.NET MVC Model Binding</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/aspnetmvc">aspnetmvc</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://sparkviewengine.com/usage/intellisense">Intellisense | Spark View Engine</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/Spark%2C">Spark,</a> <a href="http://delicious.com/savagekid/Intellisense">Intellisense</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://west-wind.com/Weblog/posts/899303.aspx">Integrating OpenID in an ASP.NET MVC Application using DotNetOpenAuth &#8211; Rick Strahl&#39;s Web Log</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/aspnetmvc%2C">aspnetmvc,</a> <a href="http://delicious.com/savagekid/openid">openid</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://weblogs.asp.net/scottgu/archive/2010/01/10/asp-net-mvc-2-strongly-typed-html-helpers.aspx">ASP.NET MVC 2: Strongly Typed Html Helpers &#8211; ScottGu&#39;s Blog</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/aspnetmvc">aspnetmvc</a>)</div>
</li>
</ul>
<br />  <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=501&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/2leggedspider/~4/nQ4K7l-IWFY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://2leggedspider.wordpress.com/2010/01/11/links-for-2010-01-11/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3f32eca38c5ea5d1d86681bc09214cf2?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">SavageKid</media:title>
		</media:content>
	<feedburner:origLink>http://2leggedspider.wordpress.com/2010/01/11/links-for-2010-01-11/</feedburner:origLink></item>
		<item>
		<title>Create a custom Outlook holiday file</title>
		<link>http://feedproxy.google.com/~r/2leggedspider/~3/yr7LJminXBU/</link>
		<comments>http://2leggedspider.wordpress.com/2010/01/08/create-a-custom-outlook-holiday-file/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 07:40:36 +0000</pubDate>
		<dc:creator>Sumit Thomas</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[outlook]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://2leggedspider.wordpress.com/?p=478</guid>
		<description><![CDATA[Like many of my friends, the first thing I check at the start of the year is the list of public holidays for that year. Outlook&#8217;s holiday feature comes really handy as it makes it convenient for me to update my Calendar with a predefined list of holidays. To add a predefined holiday list to [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=478&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Like many of my friends, the first thing I check at the start of the year is the list of public holidays for that year. Outlook&#8217;s holiday feature comes really handy as it makes it convenient for me to update my Calendar with a predefined list of holidays.</p>
<p>To add a predefined holiday list to your Outlook calendar go to Tools -&gt; Options -&gt; Calendar Options -&gt; Add Holidays and select your country and click OK.</p>
<p><a href="http://2leggedspider.files.wordpress.com/2010/01/outlook_cal_options.png"><img class="aligncenter size-full wp-image-479" title="outlook_cal_options" src="http://2leggedspider.files.wordpress.com/2010/01/outlook_cal_options.png?w=720" alt=""   /></a></p>
<p><a href="http://2leggedspider.files.wordpress.com/2010/01/outlook_add_hol.png"><img class="aligncenter size-full wp-image-480" title="outlook_add_hol" src="http://2leggedspider.files.wordpress.com/2010/01/outlook_add_hol.png?w=720" alt=""   /></a></p>
<p>The predefined holiday list is stored in the file  Outlook.hol which is called as the Outllook holiday file.</p>
<p>You don&#8217;t have to stick to the predefined list as you can edit this file and add your custom holidays using a notepad.</p>
<p>A holiday file has the following format&#8230;</p>
<p style="padding-left:30px;"><strong>[Section Name] [Number of Holidays]<br />
Holiday Description, yyyy/mm/dd<br />
Holiday Description, yyyy/mm/dd<br />
Holiday Description, yyyy/mm/dd<br />
</strong>and so on..</p>
<p>You can have as many sections as you want.</p>
<p>So what if you want to create your Company specific holiday list? Suppose there is a fictional company ABC, which has branches in Chennai, Bangalore and US. You can create a custom holiday file for this company which can be distributed to all its employees. To do so&#8230;</p>
<ol>
<li>Open notepad and paste the following&#8230;
<pre><span style="color:#800000;">[ABC Bangalore Office 2010] 15
Makara Sankranthi    ,2010/1/14
Republic Day        ,2010/1/26
Maha Shivarathri    ,2010/2/12
Ugadi            ,2010/3/16
Good Friday        ,2010/4/2
May Day            ,2010/5/1
Independence Day    ,2010/8/15
Janmashtami        ,2010/9/1
Id-ul-fitr (Ramzan)     ,2010/9/10
Gandhi Jayanti        ,2010/10/2
Vijaya Dashami        ,2101/10/17
State Formation Day    ,2010/11/1
Deepavali        ,2010/11/5
Bakrid            ,2010/11/17
Christmas        ,2010/12/25

[ABC Chennai Office 2010] 13
Pongal            ,2010/1/14
Republic Day        ,2010/1/26
Maha Shivarathri    ,2010/2/12
Good Friday        ,2010/4/2
May Day            ,2010/5/1
Independence Day    ,2010/8/15
Janmashtami        ,2010/9/1
Id-ul-fitr (Ramzan)     ,2010/9/10
Gandhi Jayanti         ,2010/10/2
State Formation Day    ,2010/11/1
Deepavali        ,2010/11/5
Bakrid            ,2010/11/17
Christmas        ,2010/12/25

[ABC US Office 2010] 11
Memorial Day        ,2010/5/31
Independence Day    ,2010/7/5
Labor Day        ,2010/9/6
Thanksgiving Holiday    ,2010/11/25
Thanksgiving Holiday    ,2010/11/26
US Corporate Holiday    ,2010/12/20
US Corporate Holiday    ,2010/12/21
US Corporate Holiday    ,2010/12/22
US Corporate Holiday    ,2010/12/23
US Corporate Holiday    ,2010/12/24
New Year's Eve        ,2010/12/31</span></pre>
</li>
<li>Save this file as <em>ABC 2010 Holidays.hol</em></li>
</ol>
<p>To use this file just double click and select the sections you want to add to your Calendar.</p>
<p><a href="http://2leggedspider.files.wordpress.com/2010/01/abc-holiday.png"><img class="aligncenter size-full wp-image-486" title="abc holiday" src="http://2leggedspider.files.wordpress.com/2010/01/abc-holiday.png?w=720" alt=""   /></a></p>
<p>This file can be distributed to all the ABC employees through email or a shared location.</p>
<p>Hope you found it useful!<div class="tweetmeme-button" id="tweetmeme-button-post-478" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2F2leggedspider.wordpress.com%2F2010%2F01%2F08%2Fcreate-a-custom-outlook-holiday-file%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpsQk-7I%26tweetmeme_source%3Dwordpressdotcom"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2F2leggedspider.wordpress.com%2F2010%2F01%2F08%2Fcreate-a-custom-outlook-holiday-file%2F" height="61" width="51" /></a>
</div></p>
<br /> Tagged: outlook, Tips <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=478&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/2leggedspider/~4/yr7LJminXBU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://2leggedspider.wordpress.com/2010/01/08/create-a-custom-outlook-holiday-file/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3f32eca38c5ea5d1d86681bc09214cf2?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">SavageKid</media:title>
		</media:content>

		<media:content url="http://2leggedspider.files.wordpress.com/2010/01/outlook_cal_options.png" medium="image">
			<media:title type="html">outlook_cal_options</media:title>
		</media:content>

		<media:content url="http://2leggedspider.files.wordpress.com/2010/01/outlook_add_hol.png" medium="image">
			<media:title type="html">outlook_add_hol</media:title>
		</media:content>

		<media:content url="http://2leggedspider.files.wordpress.com/2010/01/abc-holiday.png" medium="image">
			<media:title type="html">abc holiday</media:title>
		</media:content>
	<feedburner:origLink>http://2leggedspider.wordpress.com/2010/01/08/create-a-custom-outlook-holiday-file/</feedburner:origLink></item>
		<item>
		<title>Spark View Engine for ASP.NET MVC</title>
		<link>http://feedproxy.google.com/~r/2leggedspider/~3/HznCAu53asA/</link>
		<comments>http://2leggedspider.wordpress.com/2010/01/05/spark-view-engine-for-asp-net-mvc-part-1/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 14:01:28 +0000</pubDate>
		<dc:creator>Sumit Thomas</dc:creator>
				<category><![CDATA[ASPNETMVC]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Spark]]></category>
		<category><![CDATA[ViewEngine]]></category>

		<guid isPermaLink="false">http://2leggedspider.wordpress.com/?p=426</guid>
		<description><![CDATA[There&#8217;s been a lot of buzz around the new View Engine for ASP.NET called Spark. Spark is an open-source ASP.NET ViewEngine developed by Louis DeJardin (Listen to the conversation between Scott Hanselman and Louis DeJardin to get some insights on Spark). Spark works for both Monorail and ASP.NET MVC supporting C#, VB, IronPython and IronRuby. [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=426&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>There&#8217;s been a lot of buzz around the new View Engine for ASP.NET called <a href="http://sparkviewengine.com/"><strong>Spark</strong></a>. Spark is an <a href="http://sparkviewengine.codeplex.com/">open-source ASP.NET ViewEngine</a> developed by <a href="http://whereslou.com/">Louis DeJardin</a> (Listen to the <a href="http://www.hanselminutes.com/default.aspx?showID=210">conversation</a> between Scott Hanselman and Louis DeJardin to get some insights on Spark). Spark works for both Monorail and ASP.NET MVC supporting C#, VB, IronPython and IronRuby.</p>
<p>There are <a href="http://codebetter.com/blogs/jeffrey.palermo/archive/2008/01/27/mvccontrib-now-offers-four-4-alternative-view-engines-for-asp-net-mvc.aspx">other</a> ViewEngines already available as an alternative to the default ASP.NET MVC ViewEngine. Honestly I have not tried anyone of them and I surely don&#8217;t have any clue as to whether they are better or worse compared to Spark. Well, I just like everyone else decided to follow the buzz and try out Spark.</p>
<p>I decided to develop a simple RSS Reader using ASP.NET MVC and with Spark as its ViewEngine. I am using the <a href="http://sparkviewengine.com/documentation/">Spark</a> documentation as reference for my experiment.</p>
<p>Lets look at how a Spark View differs from the regular ASP.NET MVC View. Consider the following View which we are familiar with&#8230;</p>
<pre class="brush: python; title: ; notranslate">
 &lt;%@ Page Title=&quot;&quot; Language=&quot;C#&quot; Inherits=&quot;System.Web.Mvc.ViewPage&lt;IEnumerable&lt;Product&gt;&gt;&quot; %&gt;
 &lt;% if (Model.Count() &gt; 0)
   { %&gt;
&lt;% foreach (var product in Model)
   { %&gt;
&lt;li&gt;
    &lt;%= product.Name %&gt;
&lt;/li&gt;
&lt;% } %&gt;
&lt;%}
   else
   {%&gt;
&lt;p&gt;
    No products available&lt;/p&gt;
&lt;%} %&gt;
</pre>
<p>The equivalent Spark View would be&#8230;</p>
<pre class="brush: python; title: ; notranslate">
&lt;viewdata products=&quot;IEnumerable[[Product]]&quot;/&gt;
&lt;ul if=&quot;products.Any()&quot;&gt;
  &lt;li each=&quot;var p in products&quot;&gt;${p.Name}&lt;/li&gt;
&lt;/ul&gt;
&lt;else&gt;
  &lt;p&gt;No products available&lt;/p&gt;
&lt;/else&gt;
</pre>
<p>As you can see it is much cleaner and readable than the regular View. Checkout the <a href="http://sparkviewengine.com/documentation/syntax">Spark syntax</a> in detail. Spark makes is really simple to data bind HTML elements to objects from the Controller.</p>
<h2>Configuring ASP.NET MVC Project to use Spark ViewEngine</h2>
<p>With this background on Spark, lets jump straight in to the task of configuring a ASP.NET MVC Web application to use Spark as its default ViewEngine.</p>
<p><strong>Step 1:</strong> Download the Spark binaries from <a href="http://sparkviewengine.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=27600">here</a>. Extract the zip file and locate the bin folder.</p>
<p><strong>Step 2:</strong> Create a new ASP.NET MVC Web Application and add reference to the assemblies <em>Spark.dll </em>and <em>Spark.Web.Mvc.dll</em></p>
<p><img src="http://2leggedspider.files.wordpress.com/2010/01/spark_reference.png?w=720" alt="Spark reference" /></p>
<p><strong>Step 3:</strong> Add Spark to the ViewEngine collection in the Application_Start section of Global.asax</p>
<pre class="brush: csharp; title: ; notranslate">
        protected void Application_Start()
        {
            ViewEngines.Engines.Add(new SparkViewFactory());
            RegisterRoutes(RouteTable.Routes);
        }
</pre>
<p>Your application is now ready for Spark!</p>
<p><strong>Step 4:</strong> You may also add the following configuration settings in your web.config</p>
<pre class="brush: xml; title: ; notranslate">
	&lt;configSections&gt;
		&lt;section name=&quot;spark&quot; type=&quot;Spark.Configuration.SparkSectionHandler, Spark&quot;/&gt;
	&lt;/configSections&gt;
	&lt;spark&gt;
		&lt;compilation debug=&quot;true&quot;/&gt;
		&lt;pages automaticEncoding=&quot;true&quot;&gt;
		&lt;namespaces&gt;
                &lt;add namespace=&quot;System.Web.Mvc&quot;/&gt;
                &lt;add namespace=&quot;System.Web.Mvc.Ajax&quot;/&gt;
                &lt;add namespace=&quot;System.Web.Mvc.Html&quot;/&gt;
                &lt;add namespace=&quot;System.Web.Routing&quot;/&gt;
                &lt;add namespace=&quot;System.Linq&quot;/&gt;
                &lt;add namespace=&quot;System.Collections.Generic&quot;/&gt;
		&lt;/namespaces&gt;
		&lt;/pages&gt;
	&lt;/spark&gt;
</pre>
<p>Another way of providing the Spark Engine settings is by creating an instance of ISparkSettings and passing it to the constructor of SparkViewFactory&#8230;</p>
<pre class="brush: csharp; title: ; notranslate">
protected void Application_Start(object sender, EventArgs e)
{
    var settings = new SparkSettings()
        .SetDebug(true)
        .AddNamespace(&quot;System.Web.Mvc&quot;)
        .AddNamespace(&quot;System.Web.Mvc.Ajax&quot;)
        .AddNamespace(&quot;System.Web.Mvc.Html&quot;)
        .AddNamespace(&quot;System.Web.Routing&quot;)
        .AddNamespace(&quot;System.Linq&quot;)
        .AddNamespace(&quot;System.Collections.Generic&quot;);

    ViewEngines.Engines.Add(new SparkViewFactory(settings));
}
</pre>
<p>Thats all you have to do in terms of setting up the MVC Web application to use Spark ViewEngine.</p>
<h2>Spark View Layouts</h2>
<p>So far we have only configured the application to use Spark ViewEngine. Spark Views have a different extension from the regular ASP.NET MVC Views and as we saw already, they have a different syntax as well. Spark Views have the extension <strong>.spark</strong>. The way Spark ViewEngine deals with Master pages is also different. Lets look at it&#8230;</p>
<p><span style="text-decoration:underline;"><br />
</span></p>
<h3><span style="text-decoration:underline;">Master Pages</span></h3>
<p><span style="text-decoration:underline;"> </span></p>
<p><span style="text-decoration:underline;"> </span></p>
<p>Application.spark &#8211; This is the application wide Master page which will be used by the Spark Engine. It could be place in Views/Layouts folder or Views/Shared folder.</p>
<p>[ControllerName].spark &#8211; If you need to use a Master page for individual Controllers then you can create a spark file with the name of the Controller. For instance if you have a HomeController then Views/Layouts/Home.spark or Views/Shared/Home.spark would be Master page for that Controller.</p>
<p><a href="http://sparkviewengine.com/documentation/master-layouts">Check</a> the <strong>Selecting Layout</strong> section in Spark documentation for more details.</p>
<p><span style="text-decoration:underline;"><br />
</span></p>
<h3><span style="text-decoration:underline;">Partial Views or User Controls</span></h3>
<p><span style="text-decoration:underline;"> </span></p>
<p><span style="text-decoration:underline;"> </span></p>
<p>Any partial view prefixed with an underscore can have its own tag in Spark. For instance if we have a Partial View _LogOnUserControl.spark then we can refer to it in the Spark View as &lt;LogOnUserControl /&gt;. If you don&#8217;t like this convention then you can remove the underscore and refer to the Partial View as &lt;use file=&#8221;LogOnUserControl&#8221; /&gt;</p>
<p>With these changes in place our Views layout will look like this&#8230;</p>
<p><img src="http://2leggedspider.files.wordpress.com/2010/01/spark_view_layout.png?w=720" alt="Spark View Layout" /></p>
<p>Let&#8217;s look at the individual Spark Views as to how they differ from the regular Views that you get when you create a new ASP.NET MVC Web Application.</p>
<p><span style="text-decoration:underline;"><br />
</span></p>
<h3><span style="text-decoration:underline;">Application.spark (replaces Site.master)</span></h3>
<p><span style="text-decoration:underline;"> </span></p>
<p><span style="text-decoration:underline;"> </span></p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head id=&quot;Head1&quot; runat=&quot;server&quot;&gt;
    &lt;title&gt;
        &lt;use content=&quot;title&quot;&gt;Default title&lt;/use&gt;
    &lt;/title&gt;
    &lt;link href=&quot;~/Content/Site.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div class=&quot;page&quot;&gt;
        &lt;div id=&quot;header&quot;&gt;
            &lt;div id=&quot;title&quot;&gt;
                &lt;h1&gt;
                    My MVC Application&lt;/h1&gt;
            &lt;/div&gt;
            &lt;div id=&quot;logindisplay&quot;&gt;
                &lt;LogOnUserControl&quot; /&gt; // or &lt;use file=&quot;_LogOnUserControl&quot; /&gt;
            &lt;/div&gt;
            &lt;div id=&quot;menucontainer&quot;&gt;
                &lt;ul id=&quot;menu&quot;&gt;
                    &lt;li&gt;!{Html.ActionLink(&quot;Home&quot;, &quot;Index&quot;, &quot;Home&quot;)}&lt;/li&gt;
                    &lt;li&gt;!{Html.ActionLink(&quot;About&quot;, &quot;About&quot;, &quot;Home&quot;)}&lt;/li&gt;
                &lt;/ul&gt;
            &lt;/div&gt;
        &lt;/div&gt;
        &lt;div id=&quot;main&quot;&gt;
            &lt;use content=&quot;view&quot; /&gt;
            &lt;div id=&quot;footer&quot;&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>We can create Home.spark as well in the same manner.</p>
<p><span style="text-decoration:underline;"><br />
</span></p>
<h3><span style="text-decoration:underline;">Index.spark(replaces Index.aspx)</span></h3>
<p><span style="text-decoration:underline;"> </span></p>
<p><span style="text-decoration:underline;"> </span></p>
<pre class="brush: python; title: ; notranslate">
&lt;content name=&quot;title&quot;&gt;
       Home Page
&lt;/content&gt;
&lt;h2&gt;
    ${ViewData[&quot;Message&quot;]}&lt;/h2&gt;
&lt;p&gt;
    To learn more about ASP.NET MVC visit &lt;a href=&quot;http://asp.net/mvc&quot; title=&quot;ASP.NET MVC Website&quot;&gt;

http://asp.net/mvc&lt;/a&gt;.

&lt;/p&gt;
</pre>
<p><span style="text-decoration:underline;"><br />
</span></p>
<h3><span style="text-decoration:underline;">_LogOnUserControl.spark(replaces LogOnUserControl.ascx)</span></h3>
<p><span style="text-decoration:underline;"> </span></p>
<p><span style="text-decoration:underline;"> </span></p>
<pre class="brush: python; title: ; notranslate">
&lt;if condition=&quot;Request.IsAuthenticated&quot;&gt;
    Welcome &lt;b&gt;${Context.User.Identity.Name}&lt;/b&gt;!
    [ !{Html.ActionLink(&quot;Log Off&quot;, &quot;LogOff&quot;, &quot;Account&quot;)} ]
&lt;/if&gt;
&lt;else&gt;
    [ !{Html.ActionLink(&quot;Log On&quot;, &quot;LogOn&quot;, &quot;Account&quot;)} ]
&lt;/else&gt;
</pre>
<p>Run the application and you will see the usual ASP.NET MVC Web Application&#8217;s home page but rendered using Spark ViewEngine. From what I have seen so far Spark looks promising and would be a great alternative for those who feel the default ViewEngine forces them to go back to the classic ASP days. I haven&#8217;t completely gone through all the possibilities in Spark and would like do so in the next few days.</p>
<p>Share your thoughts on Spark or any other ViewEngines you may have used.<br />
<div class="tweetmeme-button" id="tweetmeme-button-post-426" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2F2leggedspider.wordpress.com%2F2010%2F01%2F05%2Fspark-view-engine-for-asp-net-mvc-part-1%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpsQk-6S%26tweetmeme_source%3Dwordpressdotcom"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2F2leggedspider.wordpress.com%2F2010%2F01%2F05%2Fspark-view-engine-for-asp-net-mvc-part-1%2F" height="61" width="51" /></a>
</div></p>
<br /> Tagged: ASPNETMVC, Spark, ViewEngine <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=426&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/2leggedspider/~4/HznCAu53asA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://2leggedspider.wordpress.com/2010/01/05/spark-view-engine-for-asp-net-mvc-part-1/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3f32eca38c5ea5d1d86681bc09214cf2?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">SavageKid</media:title>
		</media:content>

		<media:content url="http://2leggedspider.files.wordpress.com/2010/01/spark_reference.png" medium="image">
			<media:title type="html">Spark reference</media:title>
		</media:content>

		<media:content url="http://2leggedspider.files.wordpress.com/2010/01/spark_view_layout.png" medium="image">
			<media:title type="html">Spark View Layout</media:title>
		</media:content>
	<feedburner:origLink>http://2leggedspider.wordpress.com/2010/01/05/spark-view-engine-for-asp-net-mvc-part-1/</feedburner:origLink></item>
		<item>
		<title>links for 2010-01-04</title>
		<link>http://feedproxy.google.com/~r/2leggedspider/~3/eZkZx93eTGo/</link>
		<comments>http://2leggedspider.wordpress.com/2010/01/04/links-for-2010-01-04/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 12:04:32 +0000</pubDate>
		<dc:creator>Sumit Thomas</dc:creator>
				<category><![CDATA[Daily Links]]></category>

		<guid isPermaLink="false">http://2leggedspider.wordpress.com/2010/01/04/links-for-2010-01-04/</guid>
		<description><![CDATA[Rob Conery&#39;s Blog: Thoughts on ASP.NET MVP – A Framework That Wants To Be MVC (tags: aspnetmvc) Paul&#39;s MCS Developer Blog : Walkthrough: full example of using MvcContrib grid with jQuery datatable (tags: aspnetmvc, jquery,) 45 Fresh Out of the oven jQuery Plugins &#8211; Noupe (tags: jquery, plugin,) Take Your HTML Tables to a New [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=425&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="http://blog.wekeroad.com/2010/01/04/thoughts-on-aspnet-mvp--a-framework-that-wants-to-be-mvc">Rob Conery&#39;s Blog: Thoughts on ASP.NET MVP – A Framework That Wants To Be MVC</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/aspnetmvc">aspnetmvc</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://blogs.msdn.com/paulwhit/archive/2009/03/28/walkthrough-full-example-of-using-mvccontrib-grid-with-jquery-datatable.aspx">Paul&#39;s MCS Developer Blog : Walkthrough: full example of using MvcContrib grid with jQuery datatable</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/aspnetmvc%2C">aspnetmvc,</a> <a href="http://delicious.com/savagekid/jquery%2C">jquery,</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://www.noupe.com/ajax/45-fresh-out-of-the-oven-jquery-plugins.html">45 Fresh Out of the oven jQuery Plugins &#8211; Noupe</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/jquery%2C">jquery,</a> <a href="http://delicious.com/savagekid/plugin%2C">plugin,</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://www.thepixelart.com/take-your-html-tables-to-a-new-level-with-javascript-frameworks/">Take Your HTML Tables to a New Level with JavaScript Frameworks</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/savagekid/javascript%2C">javascript,</a> <a href="http://delicious.com/savagekid/html">html</a>)</div>
</li>
</ul>
<br />  <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=2leggedspider.wordpress.com&#038;blog=110876&#038;post=425&#038;subd=2leggedspider&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/2leggedspider/~4/eZkZx93eTGo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://2leggedspider.wordpress.com/2010/01/04/links-for-2010-01-04/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3f32eca38c5ea5d1d86681bc09214cf2?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">SavageKid</media:title>
		</media:content>
	<feedburner:origLink>http://2leggedspider.wordpress.com/2010/01/04/links-for-2010-01-04/</feedburner:origLink></item>
	</channel>
</rss>
