Click here to Skip to main content
15,896,336 members
Articles / Programming Languages / C#

MetaContainer - an abstraction over the dependency injection infrastructure

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
7 Mar 2009Ms-PL3 min read 20.5K   82   10  
Description of an abstraction layer over the dependency injection infrastructure
using System;
using Microsoft.Practices.ServiceLocation;

namespace MetaContainer
{
   /// <summary>
   /// A simple abstract interface over any dependency injection container.
   /// </summary>
   public interface IMetaContainer : IServiceLocator
   {
      /// <summary>
      /// Registers mapping from service interface <paramref name="from"/> to implementation class
      /// <paramref name="to"/> named <paramref name="name"/> and with <paramref name="scope"/> scope.
      /// </summary>
      /// <param name="from">Service interface type.</param>
      /// <param name="to">Service implementation type.</param>
      /// <param name="name">Name of the mapping (if named, otherwise - null).</param>
      /// <param name="scope">Scope or lifestyle of a component.</param>
      void Register(Type from, Type to, string name, Scope scope);
      /// <summary>
      /// Registers mapping from service interface <paramref name="from"/> to a method <paramref name="factoryMethod"/> producing
      /// service implementation objects. Mapping is named <paramref name="name"/> and is defined with
      /// <paramref name="scope"/>.
      /// </summary>
      /// <param name="from">Service interface type.</param>
      /// <param name="factoryMethod">A method producing service implementations.</param>
      /// <param name="name">Name of the mapping (if named, otherwise - null).</param>
      /// <param name="scope">Scope or lifestyle of a component.</param>
      void Register(Type from, Func<string, object> factoryMethod, string name, Scope scope);
      /// <summary>
      /// Creates child container for current container.
      /// </summary>
      /// <returns>A child container instance or null, if infrastructure doesn't support child
      /// container feature.</returns>
      IMetaContainer CreateChildContainer();
   }
}

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 Microsoft Public License (Ms-PL)


Written By
Software Developer (Senior) VSoft
Poland Poland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions