Click here to Skip to main content
15,886,199 members
Articles / Programming Languages / C#

Dependency Injection for .NET using a Dynamic Service Locator with Dynamic Proxy Injection

Rate me:
Please Sign up or sign in to vote.
3.45/5 (8 votes)
8 Mar 2008CPOL11 min read 37.8K   241   28  
Dependency Injection for .NET using a Dynamic Service Locator with Dynamic Proxy Injection.
/************************************************/
/* Written/Copyright by Ralph Varjabedian       */
/* Please do not remove the copyright notice    */
/************************************************/

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Reflection;

namespace DynamicServiceLocator
{
    /// <summary>
    /// The configuration section for the DynamicServiceLocator
    /// </summary>
    public class DynamicServiceLocatorConfiguration : ConfigurationSection
    {
        [ConfigurationProperty("implementers")]
        public ImplementersConfigurationElementCollection Implementers
        {
            get
            {
                return (ImplementersConfigurationElementCollection)base["implementers"];
            }
        }
        public static DynamicServiceLocatorConfiguration GetInstance
        {
            get
            {
                return (DynamicServiceLocatorConfiguration) 
                    ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location).GetSection("DynamicServiceLocator");
            }
        }

        public ImplementersConfigurationElement this[string name]
        {
            get
            {
                return Implementers[name];
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead
Lebanon Lebanon
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions