<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://codebetter.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>David Hayden [MVP C#]</title><link>http://codebetter.com/blogs/david.hayden/default.aspx</link><description>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.NET Tutorials, Patterns, and Practices</description><dc:language>en</dc:language><generator>CommunityServer 2007 (Build: 20416.853)</generator><item><title>Decorator Pattern</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/09/30/decorator-pattern.aspx</link><pubDate>Tue, 30 Sep 2008 14:39:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:183433</guid><dc:creator>David Hayden</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=183433</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/09/30/decorator-pattern.aspx#comments</comments><description>&lt;p&gt;The other day I created a screencast that showed off the Unity Interception Extension and RemotingPolicyInjector to show AOP development in .NET applications:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://www.pnpguidance.net/Screencast/UnityInterceptionExtensionRemotingPolicyInjectorScreencastUnityTutorials.aspx"&gt;Unity Interception Extension and RemotingPolicyInjector Screencast - Unity Tutorials&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;and then followed that up with a post using PostSharp 1.0 that showed the same functionality &lt;u&gt;without&lt;/u&gt; using the Unity Interception Extension:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2008/09/27/PostSharpAOPUnityIoCContainerAlternativeInterceptionExtensionRemotePolicyInjector.aspx"&gt;PostSharp AOP and Unity IoC Container - Alternative to Interception Extension and RemotingPolicyInjector&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Decorator Pattern&lt;/h2&gt;
&lt;p&gt;Continuing with this idea of showing alternatives using the same example, I thought it might be interesting to show the &lt;strong&gt;Decorator Pattern&lt;/strong&gt; which can be used when the &lt;a class="" href="http://www.pnpguidance.net/Tag/PolicyInjectionApplicationBlock.aspx"&gt;Policy Injection Application Block&lt;/a&gt; and &lt;a class="" href="http://www.pnpguidance.net/Tag/PostSharp.aspx"&gt;PostSharp&lt;/a&gt; may be overkill for your application.&lt;/p&gt;
&lt;p&gt;In the two examples mentioned above I created a Stopwatch Attribute that timed the ILogger.Write Method used in our console application:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;interface&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;ILogger&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;{&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; Write(&lt;span style="COLOR:blue;"&gt;string&lt;/span&gt; message);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;}&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;class&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;ConsoleLogger&lt;/span&gt; : &lt;span style="COLOR:#2b91af;"&gt;ILogger&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;{&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; Write(&lt;span style="COLOR:blue;"&gt;string&lt;/span&gt; message)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;*** In Logger ***&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR:blue;"&gt;string&lt;/span&gt;.Format&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;span style="COLOR:#a31515;"&gt;&amp;quot;message : {0}&amp;quot;&lt;/span&gt;, message));&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;}&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Creating these attributes is pretty simple for use in the Policy Injection Application Block and PostSharp. However, we can avoid the use of these 3rd party libraries by creating a &lt;strong&gt;StopwatchLoggerDecorator&lt;/strong&gt; Class that will achieve the same results:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;class&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;StopwatchLoggerDecorator&lt;/span&gt; : &lt;span style="COLOR:#2b91af;"&gt;ILogger&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;{&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;private&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;readonly&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;ILogger&lt;/span&gt; _inner;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; StopwatchLoggerDecorator(&lt;span style="COLOR:#2b91af;"&gt;ILogger&lt;/span&gt; inner)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _inner = inner;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; Write(&lt;span style="COLOR:blue;"&gt;string&lt;/span&gt; message)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;Stopwatch&lt;/span&gt; sw = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;Stopwatch&lt;/span&gt;();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sw.Start();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _inner.Write(message);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sw.Stop();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR:blue;"&gt;string&lt;/span&gt;.Format(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Time Elapsed: {0} ms&amp;quot;&lt;/span&gt;, sw.ElapsedMilliseconds));&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;}&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The Decorator Class implements the same ILogger Interface and takes&amp;nbsp;the &amp;quot;real&amp;quot; ILogger in&amp;nbsp;its constructor, &lt;strong&gt;ConsoleLogger. &lt;/strong&gt;Inevitably it passes the &lt;strong&gt;Write&lt;/strong&gt; Call onto the real logger, but before doing so starts a Stopwatch. After the call&amp;nbsp;to ConsoleLogger is&amp;nbsp;finished ( _inner.Write ), it stops the Stopwatch and displays the elapsed time in the console.&lt;/p&gt;
&lt;p&gt;In keeping with the examples mentioned above, one can register the ILogger in your IoC Container&amp;nbsp;/ Dependency Injection Tool of choice. Here is an example using &lt;a class="" href="http://www.pnpguidance.net/Category/Unity.aspx"&gt;Unity&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#2b91af;"&gt;IUnityContainer&lt;/span&gt; container = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;UnityContainer&lt;/span&gt;();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;// Register Logger&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#2b91af;"&gt;ILogger&lt;/span&gt; consoleLogger = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;ConsoleLogger&lt;/span&gt;();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#2b91af;"&gt;ILogger&lt;/span&gt; logger = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;StopwatchLoggerDecorator&lt;/span&gt;(consoleLogger);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;container.RegisterInstance&amp;lt;&lt;span style="COLOR:#2b91af;"&gt;ILogger&lt;/span&gt;&amp;gt;(logger,&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;ContainerControlledLifetimeManager&lt;/span&gt;());&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;// Use Logger&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;var&lt;/span&gt; registeredLogger = container.Resolve&amp;lt;&lt;span style="COLOR:#2b91af;"&gt;ILogger&lt;/span&gt;&amp;gt;();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;registeredLogger.Write(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Hello!&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#2b91af;"&gt;Console&lt;/span&gt;.ReadLine();&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The results are as follows:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img title="Decorator Pattern" style="WIDTH:365px;HEIGHT:199px;" height="199" alt="Decorator Pattern" src="http://codebetter.com/photos/david.hayden/images/183428/original.aspx" width="365" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Although a&amp;nbsp;simple example, you can use this with all sorts or cross-cutting concerns or anytime you want to decorate existing classes without modifying them. Note how easy it is to remove the functionality without modifying any of the classes. You simply just change the configuration code to no longer use the decorator.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#2b91af;"&gt;IUnityContainer&lt;/span&gt; container = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;UnityContainer&lt;/span&gt;();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;// Register Logger&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;container.RegisterType&amp;lt;&lt;span style="COLOR:#2b91af;"&gt;ILogger&lt;/span&gt;, &lt;span style="COLOR:#2b91af;"&gt;ConsoleLogger&lt;/span&gt;&amp;gt;(&lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;ContainerControlledLifetimeManager&lt;/span&gt;());&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;// Use Logger&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;var&lt;/span&gt; registeredLogger = container.Resolve&amp;lt;&lt;span style="COLOR:#2b91af;"&gt;ILogger&lt;/span&gt;&amp;gt;();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;registeredLogger.Write(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Hello!&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#2b91af;"&gt;Console&lt;/span&gt;.ReadLine();&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Although not an example of the &lt;a class="" href="http://davidhayden.com/blog/dave/archive/2005/06/04/1096.aspx"&gt;Open-Closed Principle&lt;/a&gt; ( OCP ) per se, the Decorator Pattern supports the idea that we don&amp;#39;t want to change the ConsoleLogger to add new behavior and possibly introduce bugs, but instead decorate it with another class that can offer that additional behavior. This also touches upon the &lt;a class="" href="http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx"&gt;Single-Responsibility Principle&lt;/a&gt; ( SRP ) in that the Console Logger keeps to its single responsibility of logging to the Console as opposed to adding &amp;quot;profiling&amp;quot; responsibilities to it.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Decorator Pattern at Runtime&lt;/h2&gt;
&lt;p&gt;Often you use the Decorator Pattern when it is decided at runtime whether or not you want to add the additional functionality offered by a Decorator Class.&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s re-write the code above to encapsulate the registration of our Infrastructure Services and introduce a &lt;strong&gt;debug setting&lt;/strong&gt; that decides at runtime whether or not we wish to decorate the ConsoleLogger with the StopwatchDecoratorLogger Class:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;class&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;InfrastructureExtension&lt;/span&gt; : &lt;span style="COLOR:#2b91af;"&gt;UnityContainerExtension&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;{&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;private&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;readonly&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;bool&lt;/span&gt; _debug;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; InfrastructureExtension(&lt;span style="COLOR:blue;"&gt;bool&lt;/span&gt; debug)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _debug = debug;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;protected&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;override&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; Initialize()&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;ILogger&lt;/span&gt; logger;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;if&lt;/span&gt; (_debug)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; logger = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;StopwatchLoggerDecorator&lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;ConsoleLogger&lt;/span&gt;());&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;else&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; logger = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;ConsoleLogger&lt;/span&gt;();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Container.RegisterInstance&amp;lt;&lt;span style="COLOR:#2b91af;"&gt;ILogger&lt;/span&gt;&amp;gt;(logger, &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;ContainerControlledLifetimeManager&lt;/span&gt;());&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;}&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;and now we set-up the Unity Container as follows:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#2b91af;"&gt;IUnityContainer&lt;/span&gt; container = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;UnityContainer&lt;/span&gt;();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;container.AddExtension(&lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;InfrastructureExtension&lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;false&lt;/span&gt;));&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;// Use Logger&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;var&lt;/span&gt; registeredLogger = container.Resolve&amp;lt;&lt;span style="COLOR:#2b91af;"&gt;ILogger&lt;/span&gt;&amp;gt;();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;registeredLogger.Write(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Hello!&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#2b91af;"&gt;Console&lt;/span&gt;.ReadLine();&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We can easily get the value of debug from a configuration setting, but in this case we just pass it in directly in the code above:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;container.AddExtension(&lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;InfrastructureExtension&lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;false&lt;/span&gt;));&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This will allow us to decide at runtime whether or not to decorate the ConsoleLogger with the StopwatchLoggerDecorator&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;If you prefer not to use the 3rd party &lt;a class="" href="http://www.pnpguidance.net/Tag/AOP.aspx"&gt;AOP&lt;/a&gt; style libraries, you can always get back to the basics and use the Decorator Pattern. Note that at some point the 3rd party libraries, like Policy Injection Application Block and PostSharp,&amp;nbsp;may begin to offer you much more gains in developer productivity and application maintenance if you find yourself creating a lot of decorators.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hope this helps,&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://www.davidhayden.com/"&gt;David Hayden&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Related Posts:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://www.pnpguidance.net/Post/IASATampaFebruaryMeetingIntroductionAspectOrientedProgrammingAOP.aspx"&gt;IASA Tampa February Meeting - Introduction to Aspect-Oriented Programming (AOP)&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://www.pnpguidance.net/Post/PostSharpReleasedAspectOrientedProgrammingAOPFrameworkNET.aspx"&gt;PostSharp 1.0 Released - Aspect-Oriented Programming ( AOP ) Framework for .NET&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2008/09/12/ValidationPolicyInjectionApplicationBlockEnterpriseLibraryASPNETMVC.aspx"&gt;ASP.NET MVC Validation using Policy Injection Application Block in Enterprise Library &lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2008/09/10/ASPNETMVCEnterpriseLibraryValidationApplicationBlock.aspx"&gt;ASP.NET MVC and Enterprise Library Validation Application Block&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=183433" width="1" height="1"&gt;</description></item><item><title>Unity v1.2 Screencast - Interception Extension for AOP Style Development</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/09/22/unity-v1-2-screencast-interception-extension-for-aop-style-development.aspx</link><pubDate>Mon, 22 Sep 2008 15:48:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:183136</guid><dc:creator>David Hayden</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=183136</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/09/22/unity-v1-2-screencast-interception-extension-for-aop-style-development.aspx#comments</comments><description>&lt;p&gt;&lt;a class="" title="Unity Webcast" href="http://www.pnpguidance.net/screencast/UnityInterceptionExtensionRemotingPolicyInjectorScreencastUnityTutorials.aspx"&gt;&lt;img title="Unity Screencast" style="WIDTH:318px;HEIGHT:283px;" height="283" alt="Unity Screencast" src="http://codebetter.com/photos/david.hayden/images/183133/original.aspx" width="318" align="right" border="0" /&gt;&lt;/a&gt;I mentioned the &lt;a class="" href="http://www.pnpguidance.net/Post/EnterpriseLibrary41ProjectKickoff.aspx"&gt;Enterprise Library 4.1 and Unity 1.2 Project Kickoff&lt;/a&gt; as well as how the &lt;a class="" href="http://www.pnpguidance.net/Post/Unity12FirstDropSilverlightCLRBugFixGenericDecoratorChains.aspx"&gt;first drop of Unity 1.2 has some things for Silverlight, a CLR bug fix, and support for Generic Decorator Chains&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;But probably one of the cooler parts of Unity 1.2, which is still in the&amp;nbsp;early drops,&amp;nbsp;is the migration of the &lt;a class="" href="http://www.pnpguidance.net/Category/EnterpriseLibrary.aspx"&gt;Enterprise Library&lt;/a&gt; &lt;a class="" href="http://www.pnpguidance.net/Tag/PolicyInjectionApplicationBlock.aspx"&gt;Policy Injection Application Block&lt;/a&gt;&amp;nbsp;( PIAB )&amp;nbsp;core features to a new &lt;strong&gt;Unity.Interception Assembly&lt;/strong&gt;. In the assembly is a new Unity &lt;strong&gt;Interception Extension&lt;/strong&gt; and &lt;strong&gt;RemotingPolicyInjector&lt;/strong&gt; that give you AOP Functionality built into the IoC Container itself. Of course, if you have been using Windsor, Spring, and other Dependency Injection Tools this will be old hat. It is just nice to see Unity beefing up its support so that when you want or need to use Unity you can use the very familiar PIAB functionality baked into it.&lt;/p&gt;
&lt;p&gt;To show one way to use&amp;nbsp;the new functionality, which is subject&amp;nbsp;to change,&amp;nbsp;I created a screencast:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a class="" href="http://www.pnpguidance.net/screencast/UnityInterceptionExtensionRemotingPolicyInjectorScreencastUnityTutorials.aspx"&gt;Unity Interception Extension and RemotingPolicyInjector Screencast&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This style of development is great for lifting cross-cuttings concerns out of your code as I mentioned when using the Policy Injection Application Block for helping with validation in ASP.NET MVC:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a id="_e4f2220f58181dad_HomePageDays_DaysList__ctl4_DayItem_DayList__ctl0_TitleUrl" href="http://davidhayden.com/blog/dave/archive/2008/09/12/ValidationPolicyInjectionApplicationBlockEnterpriseLibraryASPNETMVC.aspx"&gt;ASP.NET MVC Validation using Policy Injection Application Block in Enterprise Library &lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a id="_e4f2220f58181dad_HomePageDays_DaysList__ctl5_DayItem_DayList__ctl0_TitleUrl" href="http://davidhayden.com/blog/dave/archive/2008/09/10/ASPNETMVCEnterpriseLibraryValidationApplicationBlock.aspx"&gt;ASP.NET MVC and Enterprise Library Validation Application Block&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I hope the screencast is useful.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=183136" width="1" height="1"&gt;</description></item><item><title>T4 Templates for Code Generation Screencast</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/07/22/t4-templates-for-code-generation-screencast.aspx</link><pubDate>Tue, 22 Jul 2008 19:55:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:181128</guid><dc:creator>David Hayden</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=181128</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/07/22/t4-templates-for-code-generation-screencast.aspx#comments</comments><description>&lt;p&gt;&lt;a class="" title="Code Generation in Visual Studio Screencast" href="http://www.pnpguidance.net/Screencast/T4TemplatesVisualStudioCodeGenerationScreencast.aspx"&gt;&lt;img title="T4 Template Screencast" style="WIDTH:318px;HEIGHT:283px;" height="283" alt="T4 Template Screencast" src="http://codebetter.com/photos/david.hayden/images/181127/original.aspx" width="318" align="right" border="0" /&gt;&lt;/a&gt;I put together a quick screencast showing how to leverage T4 Templates in Visual Studio 2008 for Code Generation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://www.pnpguidance.net/Screencast/T4TemplatesVisualStudioCodeGenerationScreencast.aspx"&gt;T4 Templates in Visual Studio for Code Generation Screencast&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;I show step-by-step how to create a simple T4 Template and then how to generate various Entity, Data Access Object, and Factory Classes using more advanced T4 Templates that one might use&amp;nbsp;to create&amp;nbsp;a simple custom data access layer. I have seen other screencasts that have used &lt;a class="" title="SMO Tutorials" href="http://davidhayden.com/blog/dave/category/51.aspx?Show=All"&gt;SQL Server Management Objects&lt;/a&gt;, but in my case I use database schema related functionality in good &amp;#39;ol ADO.NET. Although I wouldn&amp;#39;t use this technique to build a data access layer given all the cool &lt;a class="" title="Code Generation Tools" href="http://davidhayden.com/blog/dave/category/15.aspx?Show=All"&gt;code generators&lt;/a&gt; and &lt;a class="" title=".NET O/R Mappers" href="http://davidhayden.com/blog/dave/category/24.aspx?Show=All"&gt;O/R Mappers&lt;/a&gt;, it is a pretty decent way to show the possibilities with T4 Templates.&lt;/p&gt;
&lt;p&gt;I picked up a new iPhone 3G the other day and absolutely love it, so I also created a version of the screencast that you can download and play on the iPhone. In fact, several of the more recent &lt;a class="" title="Screencasts" href="http://www.pnpguidance.net/Screencasts.aspx"&gt;Unity and Enterprise Library 4.0 Screencasts&lt;/a&gt; now have an iPhone version.&lt;/p&gt;
&lt;p&gt;If you are interested in some of the ADO.NET techniques I used in the screencast to get database schema information, check out the show notes with links to various tutorials.&lt;/p&gt;
&lt;p&gt;I hope the screencast is useful.&lt;/p&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=181128" width="1" height="1"&gt;</description></item><item><title>Unity IoC and ASP.NET Part II Screencast with Appearances by Autofac and Ninject</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/07/01/unity-ioc-and-asp-net-part-ii-screencast-with-appearances-by-autofac-and-ninject.aspx</link><pubDate>Tue, 01 Jul 2008 19:12:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:180172</guid><dc:creator>David Hayden</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=180172</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/07/01/unity-ioc-and-asp-net-part-ii-screencast-with-appearances-by-autofac-and-ninject.aspx#comments</comments><description>&lt;p&gt;&lt;a class="" href="http://www.pnpguidance.net/Screencast/UnityAspWebDependencyInjectionGuestsAutofacNinject.aspx"&gt;&lt;img title="Unity IoC and ASP.NET Screencast" style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;WIDTH:318px;BORDER-BOTTOM:0px;HEIGHT:283px;" height="283" alt="Unity IoC and ASP.NET Screencast" src="http://codebetter.com/photos/david.hayden/images/180168/original.aspx" width="318" align="right" /&gt;&lt;/a&gt;I created a final screencast&amp;nbsp;focusing on Unity, called-&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;span id="ctl00_ContentPlaceHolder1_ThePostTitle"&gt;&lt;a class="" href="http://www.pnpguidance.net/Screencast/UnityAspWebDependencyInjectionGuestsAutofacNinject.aspx"&gt;Unity and ASP.NET Web Pages Dependency Injection Part II with Special Guests - Autofac and Ninject&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;As promised in the previous screencast:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;&lt;span id="ctl00_ContentPlaceHolder1_ThePostTitle"&gt;&lt;a class="" href="http://www.pnpguidance.net/Screencast/UnityIoCASPNETScreencastDependencyInjectionWebPages.aspx"&gt;Unity IoC and ASP.NET Screencast - Dependency Injection into Web Pages&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;I wanted to show at least one other way to accomplish dependency injection with &lt;a class="" href="http://www.pnpguidance.net/Category/Unity.aspx"&gt;Unity&lt;/a&gt; in ASP.NET Webforms Web Pages without requiring base classes for pages, masterpages, usercontrols, etc. This example highlights the use of a custom HttpModule and subscribing to the PreRequestHandlerExecute Event. This is a very common method that I mentioned being used&amp;nbsp;in the&amp;nbsp;older Web Client Software Factory v1.0 and 1.1 as well as currently in Autofac via the &lt;strong&gt;DependencyInjectionModule&lt;/strong&gt; in &lt;strong&gt;Autofac.Integration.Web&lt;/strong&gt;. I am sure it is being used numerous other places as well.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;During the screencast I discuss two other dependency injection tools, &lt;strong&gt;Autofac&lt;/strong&gt; and &lt;strong&gt;Ninject&lt;/strong&gt;, which are wonderful IoC Containers that are open-source, lightweight, and easy-to-use as well as offer some wonderful integrations with Webforms, ASP.NET MVC Framework, Winforms, WCF, and various other 3rd party open-source&amp;nbsp;libraries like Castle DynamicProxy2, Log4Net, etc.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;During the screencast I show a custom HttpModule, &lt;strong&gt;NinjectHttpModule&lt;/strong&gt;, that I created and added to my copy of &lt;strong&gt;Ninject.Framework.Web&lt;/strong&gt; to offer this same functionality&amp;nbsp;with Ninject. Using inspiration from both Autofac and Ninject, I then&amp;nbsp;show a &lt;strong&gt;Unity.Integrations.Web&lt;/strong&gt; Assembly that uses techniques from both Autofac and Ninject to provide this functionality with Unity.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;In addition to Unity, I highly recommend you check out Autofac and Ninject. Download the source code and binaries, check out the examples on the wiki&amp;#39;s, and get involved in the discussion groups:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;a class="" href="http://code.google.com/p/autofac/"&gt;Autofac&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;a class="" href="http://www.ninject.org/"&gt;Ninject&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span&gt;&lt;span&gt;You can find links to samples I have created using Autofac and Ninject in the screencast show notes.&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;
&lt;p&gt;Hope you enjoy the &lt;a class="" href="http://www.pnpguidance.net/Screencast/UnityAspWebDependencyInjectionGuestsAutofacNinject.aspx"&gt;screencast&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=180172" width="1" height="1"&gt;</description></item><item><title>C# 3.0 Language Features and LINQ Heroes Happen Here Presentation</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/06/22/c-3-0-language-features-and-linq-heroes-happen-here-presentation.aspx</link><pubDate>Sun, 22 Jun 2008 15:29:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:179590</guid><dc:creator>David Hayden</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=179590</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/06/22/c-3-0-language-features-and-linq-heroes-happen-here-presentation.aspx#comments</comments><description>&lt;p&gt;&lt;img title="C# 3.0 Language Examples" style="WIDTH:300px;HEIGHT:226px;" height="226" alt="C# 3.0 Language Examples" src="http://codebetter.com/photos/david.hayden/images/179588/original.aspx" width="300" align="right" /&gt;Yesterday we had our &lt;strong&gt;Heroes Happen Here&lt;/strong&gt; Launch Event in Sarasota, Florida. I presented the new language features in C# 3.0 as well as LINQ. It was rather cool to give this presentation, because&amp;nbsp;a couple weeks earlier I was answering questions and showing demos on these same topics in The Learning Center at TechEd 2008 in Orlando.&lt;/p&gt;
&lt;p&gt;There&amp;nbsp;was a lot of material to cover in an hour, but we got through it all with good participation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;Object and Collection Initializers&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Automatically Implemented Properties&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Partial Methods&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Implicitly Typed Local Variables&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Anonymous Types&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Extension Methods&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Lambda Expressions and Closures&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Query Expressions&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;For LINQ I showed several demos solving the same challenge using the various flavors of LINQ:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;LINQ To Objects&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;LINQ To XML&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;LINQ To SQL&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;LINQ To DataSets&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;LINQ To Entities&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;ASP.NET Dynamic Data using LINQ To SQL&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For those looking for resources on C# 3.0, I would first check out the &lt;a class="" href="http://msdn.microsoft.com/en-us/library/aa287558(VS.71).aspx"&gt;C# Language Section on MSDN&lt;/a&gt;, which has links to the language specification, downloadable samples, keywords, etc. If you don&amp;#39;t have Visual Studio, you can download the &lt;a class="" href="http://www.microsoft.com/express/vcsharp/"&gt;Visual C# 2008 Express Edition&lt;/a&gt; for free.&lt;/p&gt;
&lt;p&gt;For LINQ samples, check out the &lt;a class="" href="http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx"&gt;101 LINQ Examples on MSDN&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you are interested in books, I reviewed 4 that I really enjoyed and highly recommend on C# and LINQ:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a class="" href="http://davidhayden.com/blog/dave/archive/2008/06/08/AcceleratedCSharp2008BookReview.aspx"&gt;Accelerated C# 2008&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a class="" href="http://davidhayden.com/blog/dave/archive/2008/05/23/CSharpInDepthBookReview.aspx"&gt;C# in Depth&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a class="" href="http://codebetter.com/blogs/david.hayden/archive/2008/04/06/book-review-linq-in-action.aspx"&gt;LINQ in Action&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a class="" href="http://codebetter.com/blogs/david.hayden/archive/2008/01/12/book-review-pro-linq-language-integrated-query-in-c-2008.aspx"&gt;Pro LINQ&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;If you are looking for bite-sized examples on C# 3.0, I put together a series of C# 3.0 Language Samples when I was learning&amp;nbsp;the new C#&amp;nbsp;3.0 Language Features&amp;nbsp;myself:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a id="viewpost.ascx_TitleUrl" href="http://davidhayden.com/blog/dave/archive/2006/11/30/ExtensionMethodsCSharp.aspx"&gt;Extension Methods in C# 3.0 - C# Tutorials and Examples&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/11/30/LambdaExpressionsExtensionMethodsLINQ.aspx"&gt;Lambda Expressions Extension Methods and LINQ in C# 3.0 - C#3.0 Tutorials and Examples&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/04/ObjectInitializationExpressions.aspx"&gt;C# 3.0 Feature - Object Initialization Expressions - C# 3.0 Examples and Tutorials&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/06/AnonymousTypesCSharp.aspx"&gt;Anonymous Types in C# 3.0 Needed for LINQ&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/06/ImplicitlyTypedLocalVariables.aspx"&gt;Implicitly Typed Local Variables in C# 3.0 - The var Keyword&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/07/AutomaticallyImplementedPropertiesCSharpCompiler.aspx"&gt;Automatically Implemented Properties - Visual Studio Orcas C# Compiler - C# 3.0&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/13/QueryExpressionTranslationAndLINQ.aspx"&gt;Query Expression Translation in C# 3.0 - C# 3.0 Expression Queries and LINQ&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/18/ExpressionTrees.aspx"&gt;Expression Trees in C# 3.0 - C# 3.0 Examples and Tutorials&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/21/QueryExpressionsAnonymousTypesLambaExpressions.aspx"&gt;C# 3.0 Features - C# 3.0 Examples - Query Expressions - Anonymous Types - Lamba Expressions - Extension Methods&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/21/BuildExpressionTreesTutorialAndExamples.aspx"&gt;Expression Trees C# 3.0 Part II - Building Expression Trees - C# 3.0 Examples and Tutorials&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2007/07/19/PartialMethodsCodeGeneration.aspx"&gt;C# and VB Partial Methods in Orcas Beta 2 for Code Generation - Business Object Validation Example&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;etc...&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;I&amp;nbsp;created some &lt;a class="" href="http://davidhayden.com/blog/dave/category/59.aspx?Show=All"&gt;LINQ To SQL Tutorials&lt;/a&gt; as well. As I mentioned at the presentation, check out &lt;a class="" href="http://codebetter.com/blogs/ian_cooper/archive/2008/04/06/architecting-linq-to-sql-applications-part-8.aspx"&gt;Ian Cooper&amp;#39;s LINQ To SQL Series&lt;/a&gt;. &lt;a class="" href="http://blogs.msdn.com/mattwar/"&gt;Matt Warren&lt;/a&gt; has a great series of articles on building an IQueryable Provider for insight on how LINQ to SQL works.&lt;/p&gt;
&lt;p&gt;Thanks to everyone who attended the &lt;strong&gt;Heroes Happen Here&lt;/strong&gt; Event in Sarasota.&lt;/p&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=179590" width="1" height="1"&gt;</description></item><item><title>Unity and ASP.NET Screencast</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/06/17/unity-and-asp-net-screencast.aspx</link><pubDate>Tue, 17 Jun 2008 18:30:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:179382</guid><dc:creator>David Hayden</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=179382</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/06/17/unity-and-asp-net-screencast.aspx#comments</comments><description>&lt;p&gt;&lt;a class="" title="Patterns &amp;amp; Practices Tutorials Samples" href="http://www.pnpguidance.net/"&gt;&lt;img title="Patterns &amp;amp; Practices Guidance" style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;WIDTH:230px;BORDER-BOTTOM:0px;HEIGHT:140px;" height="140" alt="Patterns &amp;amp; Practices Guidance" src="http://codebetter.com/photos/david.hayden/images/179381/original.aspx" width="230" align="right" /&gt;&lt;/a&gt;I am still catching up after a week at TechEd and getting used to the fact that the kids are off from School for the summer. Ahhhhh... the joys and challenges of a stay-at-home Dad :)&lt;/p&gt;
&lt;p&gt;This past weekend I downloaded &lt;a class="" href="http://davidhayden.com/blog/dave/archive/2008/06/13/ScreenflowScreencastSoftwareWinsBestMacOSXLeopardApplication.aspx"&gt;Screenflow&lt;/a&gt;, which is a &lt;a class="" href="http://davidhayden.com/blog/dave/archive/2008/06/13/ScreenflowScreencastSoftwareWinsBestMacOSXLeopardApplication.aspx"&gt;screencast application for the Mac&lt;/a&gt;. My goal was to create a new &lt;a class="" href="http://www.pnpguidance.net/Screencast/UnityIoCASPNETScreencastDependencyInjectionWebPages.aspx"&gt;Unity and ASP.NET Screencast&lt;/a&gt; using Screenflow, but I need to spend a bit more time with Screenflow before I go into &amp;quot;production&amp;quot; with it. It is different enough from Camtasia, which I love, such that I need to iron out the use of Visual Studio 2008 in VMware Fusion, Apple Keynotes, the iSight Camera on the MacBook Pro, and the fact that I prefer to do the screencast using my external monitor and headset. Another week and I think I will have it all figured out.&lt;/p&gt;
&lt;p&gt;In the meantime, I went ahead and created the screencast in Camtasia, which is&amp;nbsp;a phenomenal screencast application for the PC.&amp;nbsp;Therefore, if you are interested in seeing one way to get &lt;a class="" href="http://www.pnpguidance.net/Category/Unity.aspx"&gt;Unity IoC&lt;/a&gt; to work in ASP.NET Webforms for dependency injection into your pages, check out the following screencast:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;span id="ctl00_ContentPlaceHolder1_ThePostTitle"&gt;&lt;a class="" href="http://www.pnpguidance.net/Screencast/UnityIoCASPNETScreencastDependencyInjectionWebPages.aspx"&gt;Unity IoC and ASP.NET Screencast - Dependency Injection into Web Pages&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;You can also download the code presented in the screencast.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The screencast uses a similar technique&amp;nbsp;to what you will&amp;nbsp;find in the &lt;a class="" href="http://www.pnpguidance.net/Category/WebClientSoftwareFactory.aspx"&gt;Web Client Software Factory&lt;/a&gt;, where you can derive your web pages from a base page class and then call &lt;strong&gt;UnityContainer.BuildUp&lt;/strong&gt; on the page to do property injection into the page. Of course, the WCSF does not use Unity, but the techniques are similar. Although I don&amp;#39;t show it, you can use a similar technique for your MasterPages and UserControls.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Hopefully you find the screencast useful.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;On a side-note, you might want to check out &lt;a class="" href="http://www.pnpguidance.net/Post/Ninject10ReleasedLightningFastDependencyInjectionNET.aspx"&gt;Ninject 1.0 - Lightning fast dependency injection for .NET&lt;/a&gt;, which I noticed was released in 1.0. You gotta love the contributions by the developer community.&lt;/span&gt;&lt;/p&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=179382" width="1" height="1"&gt;</description></item><item><title>Logging Application Block and Unity Screencast - EntLib 4.0</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/06/01/logging-application-block-and-unity-screencast-entlib-4-0.aspx</link><pubDate>Mon, 02 Jun 2008 03:48:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:178955</guid><dc:creator>David Hayden</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=178955</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/06/01/logging-application-block-and-unity-screencast-entlib-4-0.aspx#comments</comments><description>&lt;p&gt;&lt;a class="" href="http://www.pnpguidance.net/Screencast/EnterpriseLibrary4LoggingApplicationBlockUnityIoCScreencast.aspx"&gt;&lt;img title="Logging Application Block Screencast" style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;WIDTH:318px;BORDER-BOTTOM:0px;HEIGHT:283px;" height="283" alt="Logging Application Block Screencast" src="http://codebetter.com/photos/david.hayden/images/178954/original.aspx" width="318" align="right" /&gt;&lt;/a&gt;I created another screencast over the weekend showing how you can integrate Unity with &lt;a class="" href="http://www.pnpguidance.net/Tag/EnterpriseLibrary4.aspx"&gt;Enterprise Library 4.0&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;span id="ctl00_ContentPlaceHolder1_ThePostTitle"&gt;&lt;a class="" href="http://www.pnpguidance.net/Screencast/EnterpriseLibrary4LoggingApplicationBlockUnityIoCScreencast.aspx"&gt;Enterprise Library 4.0 Logging Application Block and Unity IoC Screencast&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;This&amp;nbsp;screencast discusses the Logging Application Block with Unity. The Logging Application Block comes with a LoggingBlockExtension that adds the various configuration information into Unity so you can inject a LogWriter Class into your custom business classes.&amp;nbsp;This is&amp;nbsp;very similar to how the Data Access Application Block works with Unity as I showed in a previous screencast:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;&lt;span id="ctl00_ContentPlaceHolder1_ThePostTitle"&gt;&lt;a class="" href="http://www.pnpguidance.net/Post/EnterpriseLibrary4DataAccessApplicationBlockDAABUnityIoCScreencast.aspx"&gt;Enterprise Library 4.0 Data Access Application Block ( DAAB ) and Unity IoC Screencast&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;The screencast walks through a Model-View-Presenter type scenario where you have an &lt;strong&gt;AddCustomerPresenter&lt;/strong&gt; Class with a dependency on an &lt;strong&gt;ICustomerDataSource&lt;/strong&gt; that has a dependency on the &lt;strong&gt;LogWriter&lt;/strong&gt; Class in the Logging Application Block.&amp;nbsp;The&amp;nbsp;screencast&amp;nbsp;shows how to create the UnityContainer, add the appropriate Enterprise Library Unity Extensions, add additional type mappings, etc. The example uses a simple Rolling&amp;nbsp;Flat File TraceListener and shows you the new Midnight Rollover Setting for incremental daily log files.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;If you are interested in the Validation Application Block with Unity, you can also check out that previous screencast as well:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span id="ctl00_ContentPlaceHolder1_ThePostTitle"&gt;&lt;a class="" href="http://www.pnpguidance.net/Screencast/EnterpriseLibrary4ValidationApplicationBlockUnityIoCScreencast.aspx"&gt;Enterprise Library 4.0 Validation Application Block and Unity IoC Screencast&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;For more information on the Logging Application Block, I have some tutorials that I wrote for Logging Application Block in Enterprise Library 2.0 that essentially still apply:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt; 
&lt;ul&gt;
&lt;div&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/02/14/2801.aspx"&gt;Enterprise Library Logging Application Block Part I - TraceListeners&lt;/a&gt; 
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/02/15/2802.aspx"&gt;Enterprise Library Logging Application Block Part II - Simple ASP.NET 2.0 Website Example - Logging Unhandled Exceptions&lt;/a&gt; 
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/02/18/2805.aspx"&gt;Enterprise Library Logging Application Block Part III - Programmatically Using Logging Application Block With No Configuration File&lt;/a&gt; 
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/02/19/2806.aspx"&gt;Enterprise Library Logging Application Block Part IV - Conclusion - Free .NET Tutorials and Examples&lt;/a&gt;&lt;/li&gt;&lt;/div&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I hope the Logging Application Block Screencast proves somewhat useful.&lt;/p&gt;
&lt;p&gt;Dave&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=178955" width="1" height="1"&gt;</description></item><item><title>Presenting C# 3.0 and LINQ at Sarasota Florida Visual Studio 2008 Launch Event</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/05/31/presenting-c-3-0-and-linq-at-sarasota-florida-visual-studio-2008-launch-event.aspx</link><pubDate>Sat, 31 May 2008 19:22:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:178923</guid><dc:creator>David Hayden</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=178923</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/05/31/presenting-c-3-0-and-linq-at-sarasota-florida-visual-studio-2008-launch-event.aspx#comments</comments><description>&lt;p&gt;Feels weird to have a Visual Studio 2008, SQL Server 2008, and Windows Server 2008 launch events happening in June, but the Sarasota Florida .NET Developer Launch Event is on Saturday, June 21, 2008 at the Sarasota Community Foundation. There are not many details published yet, but unless things change, I will be presenting the new language features in C# 3.0 as well as the various flavors of LINQ. Since I have been presenting on various Visual Studio 2008 SP1 features for quite some time, expect me to sneak in Entity Framework, Astoria, and Dynamic Data whenever possible.&lt;/p&gt;
&lt;p&gt;I haven&amp;#39;t put the presentation together yet, but expect C# 3.0&amp;nbsp;information on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;Anonymous Types&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Automatically Implemented Properties&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Extension Methods&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Implicitly Typed Local Variables&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Lambda Expressions&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Expression Trees&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Object and Collection Initializers&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Partial Methods&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;With LINQ we will probably dig into:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;LINQ To Objects&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;LINQ To Xml&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;LINQ To DataSets&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;LINQ To SQL&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;LINQ To Entities&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;and then if possible I will briefly toss in the following topics as related to the above:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;ADO.NET Entity Framework and EntityDataSource&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;ADO.NET Data Services ( Astoria )&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;ASP.NET Dynamid Data&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;All of this is tentative based on the amount of time in the session, etc., but I hope to see you at the &lt;a class="" href="http://www.flacodebrew.net/Post/SarasotaVisualStudio2008SQLServer2008WindowsServer2008LaunchEvent.aspx"&gt;Sarasota Launch Event&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a class="" title="Florida .NET Developer" href="http://www.davidhayden.com/"&gt;David Hayden&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=178923" width="1" height="1"&gt;</description></item><item><title>Day of Patterns &amp; Practices - Your Thoughts? Catch me at Party at Palermo, TechEd, Florida Tweener</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/05/31/day-of-patterns-amp-practices-your-thoughts-catch-me-at-party-at-palermo-teched-florida-tweener.aspx</link><pubDate>Sat, 31 May 2008 18:46:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:178922</guid><dc:creator>David Hayden</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=178922</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/05/31/day-of-patterns-amp-practices-your-thoughts-catch-me-at-party-at-palermo-teched-florida-tweener.aspx#comments</comments><description>&lt;p&gt;&lt;a class="" href="http://www.pnpguidance.net/"&gt;&lt;img style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;WIDTH:200px;BORDER-BOTTOM:0px;HEIGHT:210px;" height="210" src="http://codebetter.com/photos/david.hayden/images/178920/original.aspx" width="200" align="right" alt="" /&gt;&lt;/a&gt;I run a very humble free event, called &lt;a class="" href="http://www.pnpguidance.net/FreeDayPatternsAndPracticesTampa2008.aspx"&gt;Day of Patterns &amp;amp; Practices&lt;/a&gt;, which is a day long event in Tampa, Florida where we discuss various proven practices as well as&amp;nbsp;tools and technologies that support those practices. The event has a website, called &lt;a class="" href="http://www.pnpguidance.net/"&gt;PnPGuidance&lt;/a&gt;, that started out as a support site for these events but has grown into a resource on Patterns &amp;amp; Practices in general. Although a little known fact, the Day of Patterns &amp;amp; Practices was the first &amp;quot;Day Of&amp;quot; event established in Florida :)&lt;/p&gt;
&lt;p&gt;I snag two of the coolest and&amp;nbsp;generous people&amp;nbsp;you will ever meet on this planet, Jeff Barnes and Stan Schultes, to help me deliver&amp;nbsp;material that is practical and useful to day-to-day development. Although not necessarily the goal, the event&amp;nbsp;in the past&amp;nbsp;has&amp;nbsp;had a Microsoft Patterns &amp;amp; Practices focus where we talk about Enterprise Library and the numerous software factories.&lt;/p&gt;
&lt;p&gt;For example, the first event in May 2007 focused on the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;Enterprise Library&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Smart Client Software Factory&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Web Client Software Factory&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Web Service Software Factory: ASMX and WCF&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;The second event in Jan 2008 focused on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;Web Client Software Factory 2.0&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Web Service Software Factory: Modeling Edition&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Test-Driven Development&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;ASP.NET MVC Framework&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Recently with the release of Enterprise Library 4.0, ObjectBuilder 2.0, and Unity 1.1, I am already thinking about the next event with presentations such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;Enterprise Library 4.0&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;ObjectBuilder 2.0&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Unity 1.1&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Prism ( or maybe Caliburn )&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;As I think about the possible topics and the timeframe of the next Day of Patterns &amp;amp; Practices, a few things come to mind:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;I don&amp;#39;t want to do these events too often so that they lose their value.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;I worry about too much of a focus on Microsoft Patterns &amp;amp; Practices.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;I don&amp;#39;t know if the developer need is breadth or depth on these topics.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;How can I expand this to more than just Tampa, Florida?&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Since doing these events, I have received hundreds of emails from various developers, developer groups, and events both locally and internationally, to present on these topics as well as&amp;nbsp;asking if I offered training or had an event schedule where I might be traveling on these topics. Truth be told, although I consult and present on these topics to clients, the Day of Patterns &amp;amp; Practices Event is just a once or twice a year event that has been focused in Tampa, Florida&amp;nbsp;( closest Microsoft venue to my house :). I prefer to keep them free, informal, but very pragmatic and useful for day-to-day development.&lt;/p&gt;
&lt;p&gt;The original idea was to present these topics as more of a road show across Florida, but&amp;nbsp;If you&amp;nbsp;aren&amp;#39;t familiar with&amp;nbsp;the Florida .NET Developer Community, we literally have code camps, developer groups meetings, geek luncheons, geek laagers, &amp;quot;Day Of&amp;quot; events, launch events, pub clubs, etc. happening all the time. Florida is a very close knit and busy .NET Developer Community which makes it difficult to find the time and a venue for the Day of Patterns &amp;amp; Practices Events, because&amp;nbsp;the presenters present at other events all across Florida. You can thank the very cool Joe Healy, Russ Fustino, Dave Noderer, Shawn Weisfield, etc. and&amp;nbsp;others that&amp;nbsp;suport the&amp;nbsp;cool development environment. Btw, Kyle Baley&amp;#39;s Bahama .NET Developer Group is an honorary Florida .NET Developer Group :)&lt;/p&gt;
&lt;p&gt;That being said, I will be at TechEd 2008, the Florida Tweener, and&amp;nbsp;Party&amp;nbsp;at Palermo&amp;nbsp;in Orlando next week and I would love to hear from others as to what you would like to see from the Day of Patterns &amp;amp; Practices Event.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;What would you like to see as the next topics?&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Are you looking for breadth or in-depth talks?&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Would you prefer a single day event, multiple days, or possibly a series of evening events?&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Would you be interested in a Day of Patterns &amp;amp; Practices - ALT.NET Version?&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;How often would you like these events?&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Would you prefer it to be run as a paid course event with more structure?&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Would you like to see it in your city?&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;I would love to talk with other developers next week about anything :) as well as what you would like to see from the Day of Patterns &amp;amp; Practices Event. I am considering the next event to be in August in Tampa, Florida with the above presentations, but I am open to ideas and feedback. If you are interested in speaking, I am also always looking for knowledgeable developers to talk on such topics.&lt;/p&gt;
&lt;p&gt;See you next week,&lt;/p&gt;
&lt;p&gt;Dave&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=178922" width="1" height="1"&gt;</description></item><item><title>ReSharper Introspection Severity and the var Keyword</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/05/29/resharper-introspection-severity-and-the-var-keyword.aspx</link><pubDate>Thu, 29 May 2008 17:38:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:178842</guid><dc:creator>David Hayden</dc:creator><slash:comments>11</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=178842</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/05/29/resharper-introspection-severity-and-the-var-keyword.aspx#comments</comments><description>&lt;p&gt;I flagged a blog post the other day from&amp;nbsp;a news&amp;nbsp;feed where someone implied that they had removed ReSharper 4.0 Beta because they did not agree with the ReSharper 4.0 &lt;u&gt;hints&lt;/u&gt; regarding the use of the &lt;strong&gt;var&lt;/strong&gt; keyword. If you install the ReSharper 4.0 beta and don&amp;#39;t change any of the Introspection Settings in the options, ReSharper will offer you the &lt;u&gt;hint&lt;/u&gt; of using the var keyword when declaring variables, etc. It may seem like a suggestion, warning, or even an error when you see the little squiggle, but hey, it&amp;#39;s a hint.&lt;/p&gt;
&lt;p&gt;Now the beauty about these little hints, suggestions, etc.&amp;nbsp;is that&amp;nbsp;they teach you a little about what is possible in&amp;nbsp;your programming&amp;nbsp;language. Maybe you didn&amp;#39;t realize the var keyword existed and when you could and could not take advantage of it. Better yet, and here is the real kicker, you have the option of adjusting the settings:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img title="ReSharper 4.0" style="WIDTH:488px;HEIGHT:300px;" height="300" alt="ReSharper 4.0" src="http://codebetter.com/photos/david.hayden/images/178840/original.aspx" width="488" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Therefore based on your coding standards and beliefs, you have the ability to personally adjust the settings for the various hints, suggestions, warnings, errors, etc. So before you jump into the mistake of un-installing&amp;nbsp;ReSharper ( or any tool )&amp;nbsp;on such a coding style disagreement, you may want to see if you can adjust the settings to your particular style :)&lt;/p&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=178842" width="1" height="1"&gt;</description></item><item><title>EntLib 4.0 Validation Application Block and Unity Screencast</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/05/26/entlib-4-0-validation-application-block-and-unity-screencast.aspx</link><pubDate>Tue, 27 May 2008 03:05:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:178733</guid><dc:creator>David Hayden</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=178733</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/05/26/entlib-4-0-validation-application-block-and-unity-screencast.aspx#comments</comments><description>&lt;p&gt;&lt;a class="" title="Validation Application Block Screencast" href="http://www.pnpguidance.net/Screencast/EnterpriseLibrary4ValidationApplicationBlockUnityIoCScreencast.aspx"&gt;&lt;img style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;WIDTH:318px;BORDER-BOTTOM:0px;HEIGHT:283px;" height="283" src="http://codebetter.com/photos/david.hayden/images/178732/original.aspx" width="318" align="right" alt="" /&gt;&lt;/a&gt;In my last screencast I talked about integrating the Data Access Application Block with &lt;a class="" href="http://www.pnpguidance.net/Category/Unity.aspx"&gt;Unity&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://www.pnpguidance.net/Screencast/EnterpriseLibrary4DataAccessApplicationBlockDAABUnityIoCScreencast.aspx"&gt;Enterprise Library 4.0 Data Access Application Block ( DAAB ) and Unity IoC Screencast&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;In the following screencast on the Validation Application Block in &lt;a class="" title="Enterprise Library 4.0" href="http://www.pnpguidance.net/Tag/EnterpriseLibrary4.aspx"&gt;Enterprise Library 4.0&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://www.pnpguidance.net/Screencast/EnterpriseLibrary4ValidationApplicationBlockUnityIoCScreencast.aspx"&gt;Enterprise Library 4.0 Validation Application Block and Unity IoC Screencast&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;we don&amp;#39;t need to discuss Unity Extensions like in the previous screencast, because we can get really nice injection of validator classes, such as IValidator&amp;lt;Customer&amp;gt;, into our custom classes by creating a simple wrapper around the Validation Application Block and registering the wrapper with Unity.&lt;/p&gt;
&lt;p&gt;The screencast shows how to create a simple wrapper around the Validation Application Block, register it with Unity.RegisterType, access the custom validator classes via Unity.Resolve, and have Unity inject those validator classes into custom classes, such as an AddCustomerPresenter Class. The same techniques will work if you are using the ASP.NET MVC Framework and injecting validator classes into a Controller.&lt;/p&gt;
&lt;p&gt;For more information on the Validation Application Block:&lt;/p&gt;
&lt;ul&gt;
&lt;div&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/23/ValidationApplicationBlockEnterpriseLibrary3PartI.aspx"&gt;Validation Application Block in Enterprise Library 3.0 - Using Validation Facade Class - Part I&lt;/a&gt; 
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/24/ValidationApplicationBlockEnterpriseLibrary3PartII.aspx"&gt;Validation Application Block in Enterprise Library 3.0 - ValidationFactory Class - Part II&lt;/a&gt; 
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/25/ValidationApplicationBlockEnterpriseLibrary3PartIII.aspx"&gt;Validation Application Block Ruleset in Enterprise Library 3.0 - Enterprise Library 3.0 Tutorials - Part III&lt;/a&gt; 
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/25/ValidationApplicationBlockEnterpriseLibrary3PartIV.aspx"&gt;Validation Application Block - Rules in External XML Configuration File - App.Config Web.Config - Enterprise Library 3.0 - Part IV&lt;/a&gt;&lt;/li&gt;&lt;/div&gt;&lt;/ul&gt;
&lt;p&gt;You can also check out my Unity Dependency Injection Screencasts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://www.pnpguidance.net/Screencast/UnityIoCDependencyInjectionASPNETMVCFrameworkScreencast.aspx"&gt;Unity IoC - Dependency Injection in ASP.NET MVC Framework Screencast&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://www.pnpguidance.net/Screencast/UnityDependencyInjectionIoCScreencast.aspx"&gt;Unity Dependency Injection IoC Screencast&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for all the positive feedback on the previous screencast :) Enjoy!&lt;/p&gt;
&lt;p&gt;David Hayden&lt;/p&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=178733" width="1" height="1"&gt;</description></item><item><title>Enterprise Library 4.0 DAAB with Unity Screencast</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/05/20/enterprise-library-4-0-daab-with-unity-screencast.aspx</link><pubDate>Tue, 20 May 2008 19:44:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:178524</guid><dc:creator>David Hayden</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=178524</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/05/20/enterprise-library-4-0-daab-with-unity-screencast.aspx#comments</comments><description>&lt;p&gt;&lt;a class="" href="http://www.pnpguidance.net/Post/EnterpriseLibrary4DataAccessApplicationBlockDAABUnityIoCScreencast.aspx"&gt;&lt;img title="Enterprise Library 4.0 Screencast" style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;WIDTH:318px;BORDER-BOTTOM:0px;HEIGHT:283px;" height="283" alt="Enterprise Library 4.0 Screencast" src="http://codebetter.com/photos/david.hayden/images/178522/original.aspx" width="318" align="right" /&gt;&lt;/a&gt;I received a few requests for a screencast to go along with my tutorial:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2008/05/19/EnterpriseLibrary4DataAccessApplicationBlockDAABUnityIoCTutorial.aspx"&gt;Enterprise Library 4.0 Data Access Application Block ( DAAB ) and Unity IoC Tutorial - DataAccessBlockExtension&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;so I went ahead and cooked one up:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;span id="ctl00_ContentPlaceHolder1_ThePostTitle"&gt;&lt;a class="" href="http://www.pnpguidance.net/Post/EnterpriseLibrary4DataAccessApplicationBlockDAABUnityIoCScreencast.aspx"&gt;Enterprise Library 4.0 Data Access Application Block ( DAAB ) and Unity IoC Screencast&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;The screencast walks you through creating a console application that uses the Enterprise Library 4.0 Data Access Application Block for use with &lt;a class="" href="http://www.pnpguidance.net/Category/Unity.aspx"&gt;Unity&lt;/a&gt;. I show how to obtain database classes using Unity.Resolve&amp;lt;Database&amp;gt; as well as how to inject the database classes into your custom classes ( CustomerDAO in this case ).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I discuss a couple of the Unity Extension Classes, &lt;a class="" href="http://www.pnpguidance.net/Tag/EnterpriseLibraryCoreExtension.aspx"&gt;EnterpriseLibraryCoreExtension&lt;/a&gt; and &lt;a class="" href="http://www.pnpguidance.net/Tag/DataAccessBlockExtension.aspx"&gt;DataAccessBlockExtension&lt;/a&gt;, and jump into Reflector to show you what the DataAccessBlockExtension is doing behind the scenes.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You might want to take a peek at my article on the &lt;strong&gt;DatabaseConfigurationView&lt;/strong&gt; Class to get more information on how&amp;nbsp;the DataAccessBlockExtension&amp;nbsp;gets access to the &lt;a href="http://davidhayden.com/blog/dave/archive/2006/01/08/2686.aspx"&gt;Data Access Application Block&lt;/a&gt; Configuration Information to populate the UnityContainer:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2007/03/13/DatabaseConfigurationViewClassDataAccessApplicationBlock.aspx"&gt;&lt;font face="Verdana" color="#0000ff" size="2"&gt;DatabaseConfigurationView Class in Enterprise Library Data Access Application Block - Read Database Connection Strings and Configuration&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I hope the screencast is useful. Feel free to browse through any of the other &lt;a class="" href="http://www.pnpguidance.net/Screencasts.aspx"&gt;screencasts&lt;/a&gt; as well.&lt;/span&gt;&lt;/p&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=178524" width="1" height="1"&gt;</description><category domain="http://codebetter.com/blogs/david.hayden/archive/tags/Featured/default.aspx">Featured</category></item><item><title>Unity 1.1 Released and Included in Enterprise Library 4.0</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/05/19/unity-1-1-released-and-included-in-enterprise-library-4-0.aspx</link><pubDate>Mon, 19 May 2008 04:33:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:178399</guid><dc:creator>David Hayden</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=178399</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/05/19/unity-1-1-released-and-included-in-enterprise-library-4-0.aspx#comments</comments><description>&lt;p&gt;Nothing scarier than hearing about Unity 1.1 being released after Enterprise Library 4.0, but rest assured Unity 1.1 is included with Enterprise Library 4.0.&lt;/p&gt;
&lt;p&gt;Unity 1.1 fixes a few bugs and has other enhancements:&lt;/p&gt;
&lt;ul&gt;
&lt;div&gt;
&lt;li&gt;Removal of all obsolete ObjectBuilder code. 
&lt;li&gt;Fix for a bug when using lifetime managers with open generic types. 
&lt;li&gt;Fix for a bug where the RegisterType method was overriding the RegisterInstance method. 
&lt;li&gt;Performance improvement when resolving singletons. 
&lt;li&gt;Exposure of some additional internal classes as public to make it easier write extensions that need to resolve dependencies in a customized way. 
&lt;li&gt;Addition of try...catch blocks to improve the error messages returned when value resolution fails.&lt;/li&gt;&lt;/div&gt;&lt;/ul&gt;
&lt;p&gt;You can download Unity 1.1 &lt;a class="" href="http://www.microsoft.com/downloads/details.aspx?FamilyId=6A9E363C-8E0A-48D3-BBE4-C2F36423E2DF&amp;amp;displaylang=en"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;More importantly, however, I had a chance to play with Enterprise Library 4.0 and Unity this evening and created a tutorial that shows you how to use Unity with the Data Access Application Block:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class="" href="http://davidhayden.com/blog/dave/archive/2008/05/19/EnterpriseLibrary4DataAccessApplicationBlockDAABUnityIoCTutorial.aspx"&gt;Enterprise Library 4.0 Data Access Application Block ( DAAB ) and Unity IoC Tutorial - DataAccessBlockExtension&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;The other application blocks work similarly so hopefully&amp;nbsp;the tutorial&amp;nbsp;gives you an idea on how it all works.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=178399" width="1" height="1"&gt;</description></item><item><title>Enterprise Library 4.0 Released with Unity IoC Integration</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/05/16/enterprise-library-4-0-released-with-unity-ioc-integration.aspx</link><pubDate>Sat, 17 May 2008 03:20:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:178337</guid><dc:creator>David Hayden</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=178337</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/05/16/enterprise-library-4-0-released-with-unity-ioc-integration.aspx#comments</comments><description>&lt;p&gt;I was wondering just the other day when &lt;strong&gt;Enterprise Library 4.0&lt;/strong&gt; might be released and low and behold today was the day.&lt;/p&gt;
&lt;p&gt;There are no new application blocks with Enterprise Library 4.0, but there are a few enhancements to existing blocks and the much anticipated Unity IoC Integration. If you so desire, you can now use Unity to wire up your application blocks when using Enterprise Library in your applications. This is, of course, optional. You&amp;nbsp;can use the existing configuration model that has been at the core of Enterprise Library since 2.0 and replaced the Configuration Application Block.&lt;/p&gt;
&lt;p&gt;You can download Enterprise Library 4.0 &lt;a class="" href="http://www.microsoft.com/downloads/details.aspx?FamilyId=90DE37E0-7B42-4044-99BE-F8ECFBBC5B65&amp;amp;displaylang=en"&gt;here&lt;/a&gt;. I recommend you visit the &lt;a class="" href="http://msdn.microsoft.com/en-us/library/cc467894.aspx"&gt;landing page&lt;/a&gt; to learn about all the particulars of Enterprise Library 4.0.&lt;/p&gt;
&lt;p&gt;If you are a veteran Enterprise Library developer, it is essentially business as usual unless you choose to use Unity for configuration and you haven&amp;#39;t played with it yet. For more information on Unity, I have a couple of &lt;a class="" href="http://www.pnpguidance.net/Screencasts.aspx"&gt;Unity Screencasts&lt;/a&gt; and a number of &lt;a class="" href="http://www.pnpguidance.net/Category/Unity.aspx"&gt;Unity Tutorials&lt;/a&gt; on PnPGuidance:&lt;/p&gt;
&lt;ul&gt;
&lt;div&gt;
&lt;li&gt;&lt;a href="http://www.pnpguidance.net/Screencast/UnityDependencyInjectionIoCScreencast.aspx"&gt;Unity Dependency Injection IoC Screencast&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.pnpguidance.net/Screencast/UnityIoCDependencyInjectionASPNETMVCFrameworkScreencast.aspx"&gt;Unity IoC - Dependency Injection in ASP.NET MVC Framework Screencast&lt;/a&gt;&lt;/li&gt;&lt;/div&gt;&lt;/ul&gt;
&lt;p&gt;Unity is pretty simple to use as dependency injection / IoC&amp;nbsp;tools go.&lt;/p&gt;
&lt;p&gt;Over the years I have probably written well over 50 - 100 tutorials on Enterprise Library. Down right pathetic as to how much I have written on Enterprise Library actually :) It was a great learning experience, however. For the most part all of the tutorials still apply, so if you are just learning Enterprise Library feel free to go through them. Even though I broke them down into &lt;a class="" href="http://davidhayden.com/blog/dave/category/50.aspx?Show=All"&gt;Enterprise Library 2.0 Tutorials&lt;/a&gt; and &lt;a class="" href="http://davidhayden.com/blog/dave/category/60.aspx?Show=All"&gt;Enterprise Library 3.0 Tutorials&lt;/a&gt;, the information is still accurate for Enterprise Library 4.0 with possibly a few exceptions.&lt;/p&gt;
&lt;p&gt;I often get asked where to start with all the tutorials, so I usually just point people to the following introductory tutorials that focus on the fundamentals for about each application block.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/01/08/2686.aspx"&gt;Enterprise Library 2.0 Data Access Application Block&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/02/14/2801.aspx"&gt;Enterprise Library 2.0 Logging Application Block Part I - TraceListeners&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/02/15/2802.aspx"&gt;Enterprise Library 2.0 Logging Application Block Part II - Simple ASP.NET 2.0 Website Example - Logging Unhandled Exceptions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/02/18/2805.aspx"&gt;Enterprise Library 2.0 Logging Application Block Part III - Programmatically Using Logging Application Block With No Configuration File&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/02/19/2806.aspx"&gt;Enterprise Library 2.0 Logging Application Block Part IV - Conclusion - Free .NET Tutorials and Examples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/02/25/2814.aspx"&gt;Caching Application Block - Enterprise Library 2.0 - IsolatedStorage and Database Caching&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/03/02/2870.aspx"&gt;Cryptography Application Block in Enterprise Library 2.0 - Symmetric Encryption Providers - RijndaelManaged ( AES ) - Part I&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/03/05/2875.aspx"&gt;Hashing Passwords Using Enterprise Library 2.0 Cryptography Application Block - SHA1Managed Hash Provider&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/23/ValidationApplicationBlockEnterpriseLibrary3PartI.aspx"&gt;Validation Application Block in Enterprise Library 3.0 - Using Validation Facade Class - Part I&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/24/ValidationApplicationBlockEnterpriseLibrary3PartII.aspx"&gt;Validation Application Block in Enterprise Library 3.0 - ValidationFactory Class - Part II&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/25/ValidationApplicationBlockEnterpriseLibrary3PartIII.aspx"&gt;Validation Application Block Ruleset in Enterprise Library 3.0 - Enterprise Library 3.0 Tutorials - Part III&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2006/12/25/ValidationApplicationBlockEnterpriseLibrary3PartIV.aspx"&gt;Validation Application Block - Rules in External XML Configuration File - App.Config Web.Config - Enterprise Library 3.0 - Part IV&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2007/03/01/EnvironmentalOverridesEnterpriseLibrary3.aspx"&gt;Environmental Overrides in Enterprise Library 3.0 - Managing Development, Test, Staging, and Production Configurations Made Easy!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2007/03/03/PolicyInjectionApplicationBlockSample.aspx"&gt;Policy Injection Application Block Sample - Enterprise Library 3.0 Coolness&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2007/03/06/PolicyInjectionApplicationBlockExampleLogging.aspx"&gt;Policy Injection Application Block Example - Enterprise Library 3.0 Tutorials&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2007/04/03/PolicyInjectionApplicationBlockCrosscuttingConcernsVsBusinessLogic.aspx"&gt;Enterprise Library 3.0 Policy Injection Application Block - Crosscutting Concerns vs. Business Logic in AOP&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;You can also find some Enterprise Library Tutorials on &lt;a class="" title="Patterns &amp;amp; Practices Guidance" href="http://www.pnpguidance.net/"&gt;PnPGuidance&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Hope this helps,&lt;/p&gt;
&lt;p&gt;Dave&lt;/p&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=178337" width="1" height="1"&gt;</description></item><item><title>Visual Studio 2008 SP1 "Background Compiling" for C#</title><link>http://codebetter.com/blogs/david.hayden/archive/2008/05/13/visual-studio-2008-sp1-quot-background-compiling-quot-for-c.aspx</link><pubDate>Tue, 13 May 2008 18:41:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:178166</guid><dc:creator>David Hayden</dc:creator><slash:comments>8</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/david.hayden/rsscomments.aspx?PostID=178166</wfw:commentRss><comments>http://codebetter.com/blogs/david.hayden/archive/2008/05/13/visual-studio-2008-sp1-quot-background-compiling-quot-for-c.aspx#comments</comments><description>&lt;p&gt;I don&amp;#39;t know the proper term for the new functionality in Visual Studio 2008 SP1 for C# that does code anaysis and finds compilation errors without an explicit compile ( what I would term &amp;quot;Background Compilation&amp;quot; ), but Scott Guthrie provides the following description:&lt;/p&gt;
&lt;p&gt;&amp;quot;The C# code editor now identifies and displays red squiggle errors for many semantic code issues that previously required an explicit compilation to identify.&amp;nbsp; For example, if you try to declare and use an unknown type in the C# code-editor today you won&amp;#39;t see a compile error until you do a build.&amp;nbsp; Now with SP1 you&amp;#39;ll see live red squiggle errors immediately (no explicit compile required):&amp;quot;&lt;/p&gt;
&lt;p&gt;Holy time savings Batman, this is much needed functionality for those developers who are not using ReSharper or another tool that provides similar code analysis in the background. I had to jump on my development machine that is &lt;u&gt;not&lt;/u&gt; running the Visual Studio 2008 SP1 Beta just to make sure this background compilation wasn&amp;#39;t already being done in Visual Studio 2008.&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t put the feature through a thorough testing, but I was just happy that it would identify unknown classes and other little things. The red squiggles are a huge time saver.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="WIDTH:469px;HEIGHT:380px;" height="380" src="http://codebetter.com/photos/david.hayden/images/178161/original.aspx" width="469" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="WIDTH:490px;HEIGHT:382px;" height="382" src="http://codebetter.com/photos/david.hayden/images/178163/original.aspx" width="490" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is worth Visual Studio 2008 SP1 alone. And, no, I don&amp;#39;t know what performance impact this has on large projects :)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Recent Visual Studio 2008 SP1 Beta Posts:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2008/05/12/EntityDataSourceADONETEntityDataModelVisualStudio2008SP1.aspx"&gt;EntityDataSource Companion to ADO.NET Entity Data Model in Visual Studio 2008 SP1&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2008/05/13/DynamicDataEntitiesWebsitesEntityDataSourceASPNETWebsiteScaffolding.aspx"&gt;Dynamic Data Entities Websites - EntityDataSource and ASP.NET Website Scaffolding - Rapid Application Development ( RAD )&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=178166" width="1" height="1"&gt;</description></item></channel></rss>