Project Description
Provides an abstraction over dependency injection and IoC containers using the abstract factory design pattern. It was created as an alternative to the
Common Service Locator, but it does not use the
service location anti-pattern and it provides support for
releasing instances. See this
blog post for more background information.
Adapters are available for various dependency injection containers, such as
Ninject and
SimpleInjector, with more to come shortly. There are also WCF extensions available for decoupling services from DI containers.
How to Get Common Instance Factory
Binaries for the Common Instance Factory can be obtained from the
NuGet Gallery. First Install NuGet using the Visual Studio Extension Manager, then right-click on References and select "Manage NuGet Packages." Find the Common Instance Factory by searching for "commoninstancefactory" then click Install.
Common Instance Factory Adapters
Next, you will need to select one or more adapters for the Common Instance Factory. These can also be found in the
NuGet Gallery by searching for "commoninstancefactory". Select an adapter for the dependency injection container you wish to use. To date there are adapters for Ninject and SimpleInjector - but
there are more to come!
To use Common Instance Factory, first initialize the container you wish to use, then pass it to the constructor of the container-specific instance factory for the adapter you selected, specifying a type which has dependencies you wish to resolve using the container.
That's it! Download the
samples to see it all in action.
WCF Extensions
If you are using the Common Instance Factory to decouple WCF services from dependency injection containers, then be sure to get the WCF extensions for Common Instance Factory from NuGet, as well as one or more container-specific WCF adapters.
Samples
For a sample of using the Common Instance Factory, visit the
Download page or download the source and samples.
Additional Information
Check back here for examples and tutorials. Also be sure to visit Tony Sneed's blog:
http://blog.tonysneed.com.