<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Dan Rigsby - Coding Up Style &#187; Design Patterns</title>
	<atom:link href="http://www.danrigsby.com/blog/index.php/category/design-patterns/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.danrigsby.com/blog</link>
	<description>Developer.Speaker.Blogger</description>
	<lastBuildDate>Tue, 17 Nov 2009 18:29:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Unity and Enterprise Library 4.0 Release Plans</title>
		<link>http://www.danrigsby.com/blog/index.php/2008/02/28/unity-and-enterprise-library-40-release-plans/</link>
		<comments>http://www.danrigsby.com/blog/index.php/2008/02/28/unity-and-enterprise-library-40-release-plans/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 14:43:30 +0000</pubDate>
		<dc:creator>Dan Rigsby</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Design Patterns]]></category>

		<guid isPermaLink="false">http://www.danrigsby.com/blog/index.php/2008/02/28/unity-and-enterprise-library-40-release-plans/</guid>
		<description><![CDATA[As a big fan of Microsoft Enterprise Library and out of my shear excitement for Unity, I had to post this:
http://blogs.msdn.com/agile/archive/2008/02/27/entlib-unity-roadmap.aspx
March 15 &#8211; Unity 1.0 release 
March 15 &#8211; Enterprise Library 4.0 CTP (includes new features of WMI2 support, ability to provide your own cache manager, and other enhancements to the application blocks based on [...]]]></description>
			<content:encoded><![CDATA[<p>As a big fan of Microsoft Enterprise Library and out of my shear excitement for <a href="http://www.pnpguidance.net/Post/UnityDependencyInjectionContainerEnterpriseLibrary4.aspx">Unity</a>, I had to post this:</p>
<p><a title="http://blogs.msdn.com/agile/archive/2008/02/27/entlib-unity-roadmap.aspx" href="http://blogs.msdn.com/agile/archive/2008/02/27/entlib-unity-roadmap.aspx">http://blogs.msdn.com/agile/archive/2008/02/27/entlib-unity-roadmap.aspx</a></p>
<li><em>March 15</em> &#8211; Unity 1.0 release </li>
<li><em>March 15</em> &#8211; Enterprise Library 4.0 CTP (includes new features of WMI2 support, ability to provide your own cache manager, and other enhancements to the application blocks based on the community feedback (listed <a href="http://www.codeplex.com/entlib/Wiki/View.aspx?title=EntLib4%20Backlog&amp;referringTitle=Home">here</a>); note, this CTP will not include integration of blocks with Unity, just an update of OB1 to OB2) </li>
<li><em>mid-end April</em> &#8211; Enterprise Library 4.0 release (includes all of the above + integration with Unity).</li>
<p>&#160;</p>
<p>I cant wait for March 15th!&#160; Beware the <a href="http://en.wikipedia.org/wiki/Ides_of_March">Ides of March</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danrigsby.com/blog/index.php/2008/02/28/unity-and-enterprise-library-40-release-plans/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Extend the Provider Model to Make It Easy to Use</title>
		<link>http://www.danrigsby.com/blog/index.php/2008/02/22/how-to-extend-the-provider-model-to-make-it-easy-to-use/</link>
		<comments>http://www.danrigsby.com/blog/index.php/2008/02/22/how-to-extend-the-provider-model-to-make-it-easy-to-use/#comments</comments>
		<pubDate>Fri, 22 Feb 2008 19:21:33 +0000</pubDate>
		<dc:creator>Dan Rigsby</dc:creator>
				<category><![CDATA[Common Libraries]]></category>
		<category><![CDATA[Design Patterns]]></category>

		<guid isPermaLink="false">http://www.danrigsby.com/blog/index.php/2008/02/22/how-to-extend-the-provider-model-to-make-it-easy-to-use/</guid>
		<description><![CDATA[The Provider Model has been around for quite awhile now and its in use all over the .Net Framework and Enterprise Library since .Net 2.0.&#160; The provider model allows you to program against an intermediary, while the actual implementation can be defined in the app.config file.&#160; The best example of this is a data access [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://msdn2.microsoft.com/en-us/library/ms972319.aspx">Provider Model</a> has been around for quite awhile now and its in use all over the .Net Framework and <a href="http://msdn2.microsoft.com/en-us/library/aa480453.aspx">Enterprise Library</a> since .Net 2.0.&#160; The provider model allows you to program against an intermediary, while the actual implementation can be defined in the app.config file.&#160; The best example of this is a data access layer.&#160; You might program a generic data access layer, but the actual implementation may be for Sql Server or Oracle and can be decided in the app.config file.&#160; I have used the provider model to abstract things such as a data access layer, a geocoding service, an authentication system, etc.&#160; Its nice to be able to just create a different implementation and swap it out in the app.config filer.</p>
<p>There is a decent amount of information out there (including a recent <a href="http://www.rosscode.com/blog/index.php?title=draft_creating_your_own_provider_framewo&amp;more=1&amp;c=1&amp;tb=1&amp;pb=1">post by Joel Ross</a>) and there is built in support for it in <a href="http://msdn2.microsoft.com/en-us/library/system.configuration.provider.aspx">System.Configuration.Provider</a>.&#160; However, while the tools in .Net make it possible to use the Provider Model, there is little guidance and some missing features in this namespace. This article is about how to extend the provider model to make it easier to use, and give a little insight into how it might be used.&#160; We are going to specifically look at the following areas:</p>
<ol>
<li>ProviderBase extensions:
<ol>
<li>Exposing the configuration values through the provider so they can be used later in the code </li>
<li>Using the provider type as the default name if no name is specified </li>
</ol>
</li>
<li>How to create a ProvidersSection that allows you to specify the default provider to use </li>
<li>ProviderCollection extensions:
<ol>
<li>Add Generics support </li>
<li>Add the ability to get an Provider by index instead of just by name </li>
</ol>
</li>
<li>How to build a generic ProviderRepository </li>
</ol>
<p><em>Note: At the bottom of this post I have zipped up all of the code and samples in this article.&#160; The sample included is a complete working example of the basic principles outlined here.</em></p>
<h2></h2>
<h2>Definitions</h2>
<p> <strong>Abstract Provider:</strong> an abstract class that services as a base for your providers.&#160; This usually contains all abstract methods and properties or overloaded methods and implementation details that can be shared by all providers.&#160; This usually derives from <a href="http://msdn2.microsoft.com/en-us/library/system.configuration.provider.providerbase.aspx">ProviderBase</a>.   </p>
<p><strong>Provider:</strong>&#160; the actual implementation of an abstract base provider.&#160; For instance, this could be your actual SQL Server implementation of the abstract data provider.</p>
<p><strong>ProvidersSection:</strong> the configuration section used by providers in the app.config file</p>
<p><strong>ProviderCollection:</strong> a collection of providers</p>
<p><strong>ProviderRepository:</strong> a repository that abstracts the need to manually try to determine which provider to use from the app.config file and wraps up tools needed to work with provider and the entire collection of providers.</p>
<h2>ProviderBase Extensions</h2>
<p>When working with the provider model each provider is named.&#160; This is important so that each provider in the list can be recognized from the others such as:</p>
<div>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&lt;DataService defaultProvider=<span style="color: #006080">&quot;SqlDataProvider&quot;</span>&gt;
    &lt;providers&gt;
        &lt;add
            name=<span style="color: #006080">&quot;SqlDataProvider&quot;</span>
            type=<span style="color: #006080">&quot;DataAccessLayer.SqlClient.SqlDataProvider, DataAccessLayer.SqlClient&quot;</span>
        /&gt;
        &lt;add
            name=<span style="color: #006080">&quot;OracleDataProvider&quot;</span>
            type=<span style="color: #006080">&quot;DataAccessLayer.OleDb.OracleDataProvider, DataAccessLayer.OleDb&quot;</span>
        /&gt;
    &lt;/providers&gt;
&lt;/DataService&gt;</pre>
</div>
<p>&#160;</p>
<p>As you can see, each provider has a name and a type.&#160; Here is my extended implementation of ProviderBase:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">using</span> System;
<span style="color: #0000ff">using</span> System.Collections.Specialized;
<span style="color: #0000ff">using</span> System.Configuration;
<span style="color: #0000ff">using</span> System.Configuration.Provider;

<span style="color: #0000ff">namespace</span> Rigsby.Configuration.Provider
{
    <span style="color: #008000">/// &lt;summary&gt;</span>
    <span style="color: #008000">/// Provides a base implementation for the extensible provider model.</span>
    <span style="color: #008000">/// &lt;/summary&gt;</span>
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> ProviderBase : System.Configuration.Provider.ProviderBase
    {
        <span style="color: #cc6633">#region</span> Private Properties
        <span style="color: #0000ff">private</span> NameValueCollection m_Configuration = <span style="color: #0000ff">new</span> NameValueCollection();
        <span style="color: #0000ff">private</span> <span style="color: #0000ff">bool</span> m_IsInitialized = <span style="color: #0000ff">false</span>;
        <span style="color: #0000ff">private</span> <span style="color: #0000ff">string</span> m_Name = String.Empty;
        <span style="color: #cc6633">#endregion</span> Private Properties

        <span style="color: #cc6633">#region</span> Public Properties
        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Gets the configuration.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;value&gt;The configuration.&lt;/value&gt;</span>
        <span style="color: #0000ff">public</span> NameValueCollection Configuration
        {
            get
            {
                <span style="color: #0000ff">return</span> m_Configuration;
            }
        }

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Gets or sets the friendly name used to refer to the provider during configuration.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;value&gt;&lt;/value&gt;</span>
        <span style="color: #008000">/// &lt;returns&gt;The friendly name used to refer to the provider during configuration.&lt;/returns&gt;</span>
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">new</span> <span style="color: #0000ff">string</span> Name
        {
            get
            {
                <span style="color: #0000ff">return</span> m_Name;
            }
            set
            {
                m_Name = <span style="color: #0000ff">value</span>;
            }
        }

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Gets a value indicating whether this instance is initialized.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;value&gt;</span>
        <span style="color: #008000">///     &lt;c&gt;true&lt;/c&gt; if this instance is initialized; otherwise, &lt;c&gt;false&lt;/c&gt;.</span>
        <span style="color: #008000">/// &lt;/value&gt;</span>
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">bool</span> IsInitialized
        {
            get
            {
                <span style="color: #0000ff">return</span> m_IsInitialized;
            }
        }
        <span style="color: #cc6633">#endregion</span> Public Properties

        <span style="color: #cc6633">#region</span> Overrides
        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Initializes the provider.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Initialize()
        {
            Initialize(String.Empty);
        }

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Initializes the provider.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;name&quot;&gt;The friendly name of the provider.&lt;/param&gt;</span>
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Initialize(
            <span style="color: #0000ff">string</span> name)
        {
            Initialize(name, <span style="color: #0000ff">new</span> NameValueCollection());
        }

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Initializes the provider.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;name&quot;&gt;The friendly name of the provider.&lt;/param&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;config&quot;&gt;A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.&lt;/param&gt;</span>
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">void</span> Initialize(
            <span style="color: #0000ff">string</span> name,
            NameValueCollection config)
        {
            <span style="color: #0000ff">if</span> (config == <span style="color: #0000ff">null</span>)
            {
                config = <span style="color: #0000ff">new</span> NameValueCollection();
            }

            <span style="color: #008000">// Get default name if empty or null</span>
            <span style="color: #0000ff">if</span> (String.IsNullOrEmpty(name))
            {
                <span style="color: #0000ff">if</span> (!String.IsNullOrEmpty(m_Name))
                {
                    name = m_Name;
                }
                <span style="color: #0000ff">else</span>
                {
                    name = <span style="color: #0000ff">this</span>.GetType().Name;
                }
            }
            m_Name = name;

            <span style="color: #008000">// Store configuration values</span>
            m_Configuration.Clear();
            <span style="color: #0000ff">foreach</span> (<span style="color: #0000ff">string</span> key <span style="color: #0000ff">in</span> config.Keys)
            {
                m_Configuration.Add(key, config[key]);
            }

            <span style="color: #008000">// Call the base class's Initialize method</span>
            <span style="color: #0000ff">base</span>.Initialize(name, config);

            m_IsInitialized = <span style="color: #0000ff">true</span>;
        }
        <span style="color: #cc6633">#endregion</span> Overrides
    }
}</pre>
</div>
<p>The default System.Configuration.Provider.ProviderBase will hide all of the configuration values after Initialize is called.&#160; I wanted to expose this collection so that you can add in custom configuration attributes easily and access them later in your code.&#160; The default provider base would also throw exceptions if there were any unknown attributes.&#160; I found this to be undesirable. If I wanted to add a new attribute that only one of my providers might need, I would want to be able to add it without it on the fly without having to extend my provider and make sure it understood the attribute.&#160; So now based on this new ProviderBase we can do things like this:</p>
<div>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #008000">// Configuration file</span>
&lt;DataService defaultProvider=<span style="color: #006080">&quot;SqlDataProvider&quot;</span>&gt;
    &lt;providers&gt;
        &lt;add
            name=<span style="color: #006080">&quot;SqlDataProvider&quot;</span>
            type=<span style="color: #006080">&quot;DataAccessLayer.SqlClient.SqlDataProvider, DataAccessLayer.SqlClient&quot;</span>
            useStoredProcedure=<span style="color: #006080">&quot;true&quot;</span>
        /&gt;
    &lt;/providers&gt;
&lt;/DataService&gt;

<span style="color: #008000">// Code</span>
<span style="color: #0000ff">if</span> (provider.Configuration[<span style="color: #006080">&quot;useStoredProcedure&quot;</span>])
{
    <span style="color: #008000">// handle stored procedures</span>
}</pre>
</div>
<p>&#160;</p>
<p>This may not seem like much, but it can be a real time saver if you use the Provider Model a lot and need inject custom attributes.</p>
<h2>Creating a ProvidersSection</h2>
<p>In our previous example, we showed the list of providers an app.config file and the root configuration section specified a &quot;defaultProvider&quot; attribute.&#160; This is an example of the custom ProvidersSection.&#160; It&#8217;s just a generic ConfigurationSection that allows for a &quot;defaultProvider&quot; attribute and a collection of ProviderSettings.&#160; You can extend this to add your own attributes, but for most purposes any custom attributes you will need will be on the provider settings themselves and not on the ProvidersSection.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">using</span> System;
<span style="color: #0000ff">using</span> System.Configuration;

<span style="color: #0000ff">namespace</span> Rigsby.Configuration.Provider
{
    <span style="color: #008000">/// &lt;summary&gt;</span>
    <span style="color: #008000">/// A configuration section for a collection of providers.</span>
    <span style="color: #008000">/// &lt;/summary&gt;</span>
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> ProvidersSection : ConfigurationSection
    {
        <span style="color: #0000ff">private</span> <span style="color: #0000ff">const</span> <span style="color: #0000ff">string</span> m_DefaultProviderProperty = <span style="color: #006080">&quot;defaultProvider&quot;</span>;

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Gets the providers.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;value&gt;The providers.&lt;/value&gt;</span>
        [ConfigurationProperty(<span style="color: #006080">&quot;providers&quot;</span>)]
        <span style="color: #0000ff">public</span> ProviderSettingsCollection Providers
        {
            get
            {
                <span style="color: #0000ff">return</span> (ProviderSettingsCollection)<span style="color: #0000ff">base</span>[<span style="color: #006080">&quot;providers&quot;</span>];
            }
        }

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Gets or sets the default provider.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;value&gt;The default provider.&lt;/value&gt;</span>
        [ConfigurationProperty(m_DefaultProviderProperty, IsRequired=<span style="color: #0000ff">false</span>)]
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> DefaultProvider
        {
            get
            {
                <span style="color: #0000ff">return</span> (<span style="color: #0000ff">string</span>)<span style="color: #0000ff">base</span>[m_DefaultProviderProperty];
            }
            set
            {
                <span style="color: #0000ff">base</span>[m_DefaultProviderProperty] = <span style="color: #0000ff">value</span>;
            }
        }
    }
}</pre>
</div>
<h2>ProviderCollection Extensions</h2>
<p>The default ProviderCollection does not contain support for generics.&#160; This means you have to do a lot of extra casting and things aren&#8217;t strongly typed.&#160; It is also setup to only allow retrieval of providers by name.&#160;&#160; In some cases you need to be able to get the provider by index.&#160; Suppose you want to setup the provider model to try to use the first provider in the list, and if that doesn&#8217;t work, then use the next provider, and so on.&#160; If you could only get the providers by name, there is no way to easily get the next provider.&#160; The custom ProviderCollection shown below adds generics support and the ability to retrieve a provider by index.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">using</span> System;
<span style="color: #0000ff">using</span> System.Configuration;
<span style="color: #0000ff">using</span> System.Configuration.Provider;

<span style="color: #0000ff">namespace</span> Rigsby.Configuration.Provider
{
    <span style="color: #008000">/// &lt;summary&gt;</span>
    <span style="color: #008000">/// Represents a collection of provider objects that inherit from &lt;see cref=&quot;ProviderBase&quot;/&gt;.</span>
    <span style="color: #008000">/// &lt;/summary&gt;</span>
    <span style="color: #008000">/// &lt;typeparam name=&quot;T&quot;&gt;&lt;/typeparam&gt;</span>
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> ProviderCollection&lt;T&gt; : ProviderCollection
        <span style="color: #0000ff">where</span> T : Rigsby.Configuration.Provider.ProviderBase
    {
        <span style="color: #cc6633">#region</span> Public Properties
        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Gets the &lt;see cref=&quot;T:DataProvider&quot;/&gt; with the specified name.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;value&gt;&lt;/value&gt;</span>
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">new</span> T <span style="color: #0000ff">this</span>[<span style="color: #0000ff">string</span> name]
        {
            get
            {
                <span style="color: #0000ff">return</span> (T)<span style="color: #0000ff">base</span>[name];
            }
        }

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Gets the cref=&quot;&amp;lt;T&amp;gt;&quot;/&gt; at the specified index.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;value&gt;&lt;/value&gt;</span>
        <span style="color: #0000ff">public</span> T <span style="color: #0000ff">this</span>[<span style="color: #0000ff">int</span> index]
        {
            get
            {
                <span style="color: #0000ff">int</span> counter = 0;

                <span style="color: #0000ff">foreach</span>(T provider <span style="color: #0000ff">in</span> <span style="color: #0000ff">this</span>)
                {
                    <span style="color: #0000ff">if</span> (counter == index)
                    {
                        <span style="color: #0000ff">return</span> provider;
                    }
                    counter++;
                }

                <span style="color: #0000ff">return</span> <span style="color: #0000ff">null</span>;
            }
        }
        <span style="color: #cc6633">#endregion</span> Public Properties

        <span style="color: #cc6633">#region</span> Public Methods
        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Adds a provider to the collection.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;provider&quot;&gt;The provider to be added.&lt;/param&gt;</span>
        <span style="color: #008000">/// &lt;permissionSet class=&quot;System.Security.permissionSet&quot; version=&quot;1&quot;&gt;</span>
        <span style="color: #008000">///     &lt;IPermission class=&quot;System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot; version=&quot;1&quot; Flags=&quot;UnmanagedCode, ControlEvidence&quot;/&gt;</span>
        <span style="color: #008000">/// &lt;/permissionSet&gt;</span>
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">void</span> Add(
            System.Configuration.Provider.ProviderBase provider)
        {
            <span style="color: #0000ff">if</span> (!(provider <span style="color: #0000ff">is</span> T))
            {
                <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentException(
                    String.Format(&quot;The provider is not of type {0}.&quot;, <span style="color: #0000ff">typeof</span>(T).ToString()));
            }

            <span style="color: #0000ff">this</span>.Add((T)provider);
        }

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Adds the specified provider.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;provider&quot;&gt;The provider.&lt;/param&gt;</span>
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Add(
            T provider)
        {
            <span style="color: #0000ff">if</span> (!provider.IsInitialized)
            {
                provider.Initialize();
            }

            <span style="color: #0000ff">base</span>.Add(provider);
        }
        <span style="color: #cc6633">#endregion</span> Public Methods
    }
}</pre>
</div>
<h2>Creating a Generic ProviderRepository</h2>
<p>All of the changes listed above are extensions of the the default provider model to make it easier to use.&#160; The ProviderRepository though is a new concept not in the default provider model, but builds on the extensions we have already talked about.&#160; The ProviderRepository is designed to encapsulate the loading of providers from the app.config file.&#160; It will contain the list of available providers and specify which provider should be used based on the &quot;defaultProvider&quot;. It is a generic class that takes in the type of provider you are working with.&#160; For most implementations you will probably be extending ProviderBase the, so you will use ProviderRepositoy&lt;MyProviderType&gt;.&#160; For example if you have a custom data access layer provider you might call it DataProvider and use ProviderRepository&lt;DataProvider&gt;.</p>
<p>In the ProviderRepository you specify the name of the configuration section to use from the app.config file. If you leave this null or empty, then it will attempt to look for a configuration section with same name as the generic provider type.&#160; So if you created it like ProviderRepository&lt;Rigsby.Test.DataAccessLayer&gt;, then it will look for a configuration section named &lt;Rigsby.Test.DataAccessLayer&gt; in the app.config file that is a ProvidersSection.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">using</span> System;
<span style="color: #0000ff">using</span> System.Configuration;
<span style="color: #0000ff">using</span> System.Configuration.Provider;
<span style="color: #0000ff">using</span> System.Collections.Generic;
<span style="color: #0000ff">using</span> System.Text;
<span style="color: #0000ff">using</span> System.Web.Configuration;

<span style="color: #0000ff">namespace</span> Rigsby.Configuration.Provider
{
    <span style="color: #008000">/// &lt;summary&gt;</span>
    <span style="color: #008000">/// Represents a repository to give access to providers.</span>
    <span style="color: #008000">/// &lt;/summary&gt;</span>
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> ProviderRepository&lt;T&gt;
        <span style="color: #0000ff">where</span> T : ProviderBase
    {
        <span style="color: #cc6633">#region</span> Private Properties
        <span style="color: #0000ff">private</span> T m_Provider = <span style="color: #0000ff">null</span>;
        <span style="color: #0000ff">private</span> ProviderCollection&lt;T&gt; m_Providers = <span style="color: #0000ff">null</span>;
        <span style="color: #0000ff">private</span> <span style="color: #0000ff">volatile</span> <span style="color: #0000ff">object</span> m_SyncRoot = <span style="color: #0000ff">new</span> <span style="color: #0000ff">object</span>();

        <span style="color: #0000ff">private</span> <span style="color: #0000ff">string</span> m_SectionName = String.Empty;
        <span style="color: #cc6633">#endregion</span> Private Properties

        <span style="color: #cc6633">#region</span> Public Properties
        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Gets the provider.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;value&gt;The provider.&lt;/value&gt;</span>
        <span style="color: #0000ff">public</span> T Provider
        {
            get
            {
                <span style="color: #0000ff">if</span> (m_Provider == <span style="color: #0000ff">null</span> &amp;&amp; m_Providers.Count &gt; 0)
                {
                    m_Provider = m_Providers[0];
                }

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

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Gets the providers.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;value&gt;The providers.&lt;/value&gt;</span>
        <span style="color: #0000ff">public</span> ProviderCollection&lt;T&gt; Providers
        {
            get
            {
                <span style="color: #0000ff">return</span> m_Providers;
            }
        }

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Gets the name of the configuration section.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;value&gt;The name of the section.&lt;/value&gt;</span>
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> SectionName
        {
            get
            {
                <span style="color: #0000ff">return</span> m_SectionName;
            }
        }
        <span style="color: #cc6633">#endregion</span> Public Properties

        <span style="color: #cc6633">#region</span> Constructors
        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Initializes a new instance of the &lt;see cref=&quot;ProviderRepository&amp;lt;T&amp;gt;&quot;/&gt; class.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #0000ff">public</span> ProviderRepository(
            ) : <span style="color: #0000ff">this</span>(<span style="color: #0000ff">true</span>)
        {
        }

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Initializes a new instance of the &lt;see cref=&quot;ProviderRepository&amp;lt;T&amp;gt;&quot;/&gt; class.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;throwErrorIfUnableToLoadSection&quot;&gt;if set to &lt;c&gt;true&lt;/c&gt; [throw error if unable to load section].&lt;/param&gt;</span>
        <span style="color: #0000ff">public</span> ProviderRepository(
            <span style="color: #0000ff">bool</span> throwErrorIfUnableToLoadSection)
        {
            <span style="color: #0000ff">if</span> (String.IsNullOrEmpty(m_SectionName))
            {
                m_SectionName = <span style="color: #0000ff">typeof</span>(T).ToString();
            }

            LoadProviders(throwErrorIfUnableToLoadSection);
        }

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Initializes a new instance of the &lt;see cref=&quot;ProviderRepository&amp;lt;T&amp;gt;&quot;/&gt; class.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;sectionName&quot;&gt;Name of the section.&lt;/param&gt;</span>
        <span style="color: #0000ff">public</span> ProviderRepository(
            <span style="color: #0000ff">string</span> sectionName) : <span style="color: #0000ff">this</span>(sectionName, <span style="color: #0000ff">true</span>)
        {
        }

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Initializes a new instance of the &lt;see cref=&quot;ProviderRepository&amp;lt;T&amp;gt;&quot;/&gt; class.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;sectionName&quot;&gt;Name of the section.&lt;/param&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;throwErrorIfUnableToLoadSection&quot;&gt;if set to &lt;c&gt;true&lt;/c&gt; [throw error if unable to load section].&lt;/param&gt;</span>
        <span style="color: #0000ff">public</span> ProviderRepository(
            <span style="color: #0000ff">string</span> sectionName,
            <span style="color: #0000ff">bool</span> throwErrorIfUnableToLoadSection)
        {
            m_SectionName = sectionName;
            LoadProviders(throwErrorIfUnableToLoadSection);
        }

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Initializes a new instance of the &lt;see cref=&quot;ProviderRepository&amp;lt;T&amp;gt;&quot;/&gt; class.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;provider&quot;&gt;The provider.&lt;/param&gt;</span>
        <span style="color: #0000ff">public</span> ProviderRepository(
            T provider)
        {
            m_Providers = <span style="color: #0000ff">new</span> ProviderCollection&lt;T&gt;();
            m_Providers.Add(provider);

            m_Provider = provider;
        }

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Initializes a new instance of the &lt;see cref=&quot;ProviderRepository&amp;lt;T&amp;gt;&quot;/&gt; class.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;providers&quot;&gt;The providers.&lt;/param&gt;</span>
        <span style="color: #0000ff">public</span> ProviderRepository(
            ProviderCollection&lt;T&gt; providers)
        {
            m_Providers = providers;
        }
        <span style="color: #cc6633">#endregion</span> Constructors

        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Loads the providers.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">void</span> LoadProviders(
            <span style="color: #0000ff">bool</span> throwErrorIfUnableToLoadSection)
        {
            <span style="color: #008000">// Avoid claiming lock if providers are already loaded</span>
            <span style="color: #0000ff">if</span> (m_Providers == <span style="color: #0000ff">null</span>)
            {
                <span style="color: #0000ff">lock</span> (m_SyncRoot)
                {
                    <span style="color: #008000">// Do this again to make sure provider is still null</span>
                    <span style="color: #0000ff">if</span> (m_Providers == <span style="color: #0000ff">null</span>)
                    {
                        <span style="color: #008000">// Get the providers</span>
                        m_Providers = <span style="color: #0000ff">new</span> ProviderCollection&lt;T&gt;();

                        <span style="color: #008000">// Get a reference to the section</span>
                        ProvidersSection section = <span style="color: #0000ff">null</span>;
                        <span style="color: #0000ff">try</span>
                        {
                            section =
                                ConfigurationManager.GetSection(m_SectionName) <span style="color: #0000ff">as</span> ProvidersSection;
                        }
                        <span style="color: #0000ff">catch</span> (Exception)
                        {
                            section = <span style="color: #0000ff">null</span>;
                        }

                        <span style="color: #0000ff">if</span> (section == <span style="color: #0000ff">null</span>)
                        {
                            <span style="color: #0000ff">if</span> (throwErrorIfUnableToLoadSection)
                            {
                                <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ProviderException(
                                    String.Format(<span style="color: #006080">&quot;Unable to load configuration section: '{0}'.&quot;</span>,
                                        m_SectionName));
                            }
                        }
                        <span style="color: #0000ff">else</span>
                        {
                            ProvidersHelper.InstantiateProviders(section.Providers, m_Providers, <span style="color: #0000ff">typeof</span>(T));

                            <span style="color: #0000ff">if</span> (m_Providers.Count &gt; 0)
                            {
                                <span style="color: #008000">// If there is a default provider specified, then grab it, </span>
                                <span style="color: #008000">// else grab the first provider in the collection</span>
                                <span style="color: #0000ff">if</span> (!String.IsNullOrEmpty(section.DefaultProvider))
                                {
                                    m_Provider = (T)m_Providers[section.DefaultProvider];
                                }
                                <span style="color: #0000ff">else</span>
                                {
                                    m_Provider = m_Providers[0];
                                }
                            }

                            <span style="color: #0000ff">if</span> (throwErrorIfUnableToLoadSection)
                            {
                                <span style="color: #008000">// If we have no provider, then throw an exception</span>
                                <span style="color: #0000ff">if</span> (m_Provider == <span style="color: #0000ff">null</span>)
                                {
                                    <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ProviderException(
                                        String.Format(<span style="color: #006080">&quot;Unable to load default provider for section: '{0}'.&quot;</span>,
                                            m_SectionName));
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}</pre>
</div>
<h2>Putting It All Together</h2>
<p>To get this all to work you just need to do the following:</p>
<ol>
<li>Create the base provider you want to use. This should derive from ProviderBase. </li>
<li>Created at least one implementation of your base provider. This should derive from the class you made in the previous step. </li>
<li>Setup a section in your app.config file to specify the providers. </li>
<li>Create an instance of the ProviderRepository&lt;&gt; in your code that you will use to reference the provider. </li>
</ol>
<p>Below are examples of these 4 steps to put all of this together.</p>
<p><strong>Step 1 Example:</strong></p>
<div>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">abstract</span> <span style="color: #0000ff">class</span> DataProvider : ProviderBase
{
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">abstract</span> System.Data.DataTable GetRows();

    <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> GetConnectionString()
    {
        <span style="color: #0000ff">string</span> connectionStringName = <span style="color: #0000ff">this</span>.Configuration[<span style="color: #006080">&quot;connectionStringName&quot;</span>];
        <span style="color: #0000ff">if</span> (String.IsNullOrEmpty(connectionStringName))
        {
            <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ProviderException(<span style="color: #006080">&quot;Empty or missing connectionStringName&quot;</span>);
        }
        <span style="color: #0000ff">if</span> (WebConfigurationManager.ConnectionStrings[connectionStringName] == <span style="color: #0000ff">null</span>)
        {
            <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ProviderException(<span style="color: #006080">&quot;Missing connection string&quot;</span>);
        }

        <span style="color: #0000ff">return</span> WebConfigurationManager.ConnectionStrings
            [connectionStringName].ConnectionString;
    }
}</pre>
</div>
<p>&#160;</p>
<p><strong>Step 2 Example:</strong></p>
<div>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> SqlDataProvider : DataProvider
{
    <span style="color: #008000">// TODO: Implement data access layer here</span>

    <span style="color: #008000">/// &lt;summary&gt;</span>
    <span style="color: #008000">/// Gets the rows.</span>
    <span style="color: #008000">/// &lt;/summary&gt;</span>
    <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> System.Data.DataTable GetRows()
    {
        <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> System.Data.DataTable();
    }
}</pre>
</div>
<p>&#160;</p>
<p><strong>Step 3 Example:</strong></p>
<div>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&lt;?xml version=<span style="color: #006080">&quot;1.0&quot;</span> encoding=<span style="color: #006080">&quot;utf-8&quot;</span> ?&gt;
&lt;configuration&gt;
    &lt;configSections&gt;
        &lt;section name=<span style="color: #006080">&quot;DataService&quot;</span>
            type=<span style="color: #006080">&quot;Rigsby.Configuration.Provider.ProvidersSection, Rigsby.Configuration.Provider&quot;</span>
            allowDefinition=<span style="color: #006080">&quot;MachineToApplication&quot;</span>
            restartOnExternalChanges=<span style="color: #006080">&quot;true&quot;</span> /&gt;
    &lt;/configSections&gt;

    &lt;connectionStrings&gt;
        &lt;add name=<span style="color: #006080">&quot;connectionString&quot;</span>
            providerName=<span style="color: #006080">&quot;System.Data.SqlClient&quot;</span>
            connectionString=<span style="color: #006080">&quot;Data Source=localhost;Initial Catalog=DB;UID=sa;PWD=;&quot;</span> /&gt;
    &lt;/connectionStrings&gt;

    &lt;DataService defaultProvider=<span style="color: #006080">&quot;SqlDataProvider&quot;</span>&gt;
        &lt;providers&gt;
            &lt;add
                name=<span style="color: #006080">&quot;SqlDataProvider&quot;</span>
                type=<span style="color: #006080">&quot;Rigsby.Configuration.Provider.Sample.DataAccessLayer.SqlDataProvider,
                    Rigsby.Configuration.Provider.Sample&quot;</span>
                connectionStringName=<span style="color: #006080">&quot;connectionString&quot;</span>
                providerInvariantName=<span style="color: #006080">&quot;System.Data.SqlClient&quot;</span>
            /&gt;
        &lt;/providers&gt;
    &lt;/DataService&gt;
&lt;/configuration&gt;</pre>
</div>
<div>&#160;</div>
<p><strong>Step 4 Example:</strong></p>
<div>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">class</span> Program
{
    <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> ProviderRepository&lt;DataAccessLayer.DataProvider&gt; m_DatabaseProviders =
        <span style="color: #0000ff">new</span> ProviderRepository&lt;DataAccessLayer.DataProvider&gt;(<span style="color: #006080">&quot;DataService&quot;</span>);

    <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> Main(<span style="color: #0000ff">string</span>[] args)
    {
        Console.WriteLine(
            String.Format(<span style="color: #006080">&quot;ProviderName = '{0}'&quot;</span>, m_DatabaseProviders.Provider.Name));
        Console.WriteLine(
            String.Format(<span style="color: #006080">&quot;ConnectionString = '{0}'&quot;</span>, m_DatabaseProviders.Provider.GetConnectionString()));

        Console.ReadLine();
    }
}</pre>
</div>
<p>&#160;</p>
<p>Here is a link to the complete code and samples: <a title="http://www.danrigsby.com/files/rigsby.configuration.provider.zip" href="http://www.danrigsby.com/files/rigsby.configuration.provider.zip">http://www.danrigsby.com/files/rigsby.configuration.provider.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.danrigsby.com/blog/index.php/2008/02/22/how-to-extend-the-provider-model-to-make-it-easy-to-use/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enterprise Library 4.0 Product Backlog Available</title>
		<link>http://www.danrigsby.com/blog/index.php/2008/01/09/enterprise-library-40-product-backlog-available/</link>
		<comments>http://www.danrigsby.com/blog/index.php/2008/01/09/enterprise-library-40-product-backlog-available/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 12:22:32 +0000</pubDate>
		<dc:creator>Dan Rigsby</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Design Patterns]]></category>

		<guid isPermaLink="false">http://www.danrigsby.com/blog/index.php/2008/01/09/enterprise-library-40-product-backlog-available/</guid>
		<description><![CDATA[It looks like the Patterns and Practices team at Microsoft has exposed the product backlog for Enterprise Library 4.0 out on codeplex.&#160; The major new item is the Dependency Injection Application Block (DIAB) which is geared up as a more complete alternative to Spring.Net, StructureMap, Castle Windsor, and other dependency injection frameworks.&#160; The nice thing [...]]]></description>
			<content:encoded><![CDATA[<p>It looks like the Patterns and Practices team at Microsoft has exposed the <a href="http://www.codeplex.com/entlib/Wiki/View.aspx?title=EntLib4%20Backlog">product backlog for Enterprise Library 4.0</a> out on codeplex.&nbsp; The major new item is the <a href="http://blogs.msdn.com/agile/archive/2007/12/03/making-dependency-injection-simpler-in-entlib-4.aspx">Dependency Injection Application Block</a> (DIAB) which is geared up as a more complete alternative to <a href="http://www.springframework.net/">Spring.Net</a>, <a href="http://structuremap.sourceforge.net/Default.htm">StructureMap</a>, <a href="http://www.castleproject.org/container/index.html">Castle Windsor</a>, and other <a href="http://en.wikipedia.org/wiki/Dependency_injection">dependency injection</a> frameworks.&nbsp; The nice thing about this is that the base implementation of DIAB can be swapped out with one of the other engines to allow a lot more flexibility. It will&nbsp; support for containers and both declarative and imperative configuration.&nbsp; Jeremy Miller gives a much better <a href="http://codebetter.com/blogs/jeremy.miller/archive/2007/12/03/microsoft-p-amp-p-is-building-a-new-ioc-di-tool-and-i-m-okay-with-that.aspx">introduction to DIAB</a> than I ever could. It will be interesting to watch the progress they make with this and what will happen to <a href="http://www.codeplex.com/ObjectBuilder">ObjectBuilder</a> which is already a &#8220;lightweight&#8221; dependency injection framework that is used in Enterprise Library and the <a href="http://msdn.microsoft.com/library/en-us/dnpag2/html/cab.asp">Composite UI Application Block</a> (CAB). We use EntLib 3.1 and CAB extensively, so we have a vested interest in this.</p>
<p>Here are a few other items in the list that I am interested in:</p>
<ol>
<li>Provide extensibility points for Caching Block to allow alternate caching implementations (including distributed cache providers) to be plugged in. The objective here is NOT to replace the ASP.NET caching but to provide more choices.
<li>Improve performance of the Logging Block by optimizing text formatter (lazy formatting in case of the local logger, and eager formatting in case of the remote logger).
<li>Provide more descriptive error messages.</li>
<li>LAB: allow finer-grained local filters in the config tool.</li>
<li>Hands-on Labs: Validation Block, Policy Injection Block, Dependency Injection Block.</li>
<li>Allow to run multiple rulesets in Validation block.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.danrigsby.com/blog/index.php/2008/01/09/enterprise-library-40-product-backlog-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

