skip to the main content area of this page
Patterns and Practices

 

Unity Dependency Injection Container in Enterprise Library 4.0


Grigori Melnik mentions that Unity will be the name of the dependency injection application block in Enterprise Library 4.0. Unity will be released in two forms - 1) a standalone container, and 2) an application block in Enterprise Library 4.0 with the existing application blocks refactored to take advantage of Unity. Unity will support a standard API for retrieving and registering items, a fluent interface, and a ContainerExtension mechanism for third party integration.

A typical usage scenario for Unity may look like the following:

 

UnityContainer container = new UnityContainer()

    .Register<IProductCatalog, ProductCatalog>();
    .Register<IProductDescriptionService, ProductDescriptionService>();
    .Register<IProductsController, ProductsController>();

IProductCatalog catalog = container.Get<IProductCatalog>();

 

It will be interesting to see how the Policy Injection Application Block will integrate with the Unity Container. My guess is via the ContainerExtension Mechanism.

Learn more from Grigori.


Tags: Unity, EnterpriseLibrary4, DependencyInjection, IoC


Topics



 

Popular Tags



Recent Links