Skip to content

Microsoft Patterns and Practices Enterprise Library 5 support for using Autofac as the container.

License

Notifications You must be signed in to change notification settings

autofac/Autofac.Extras.EnterpriseLibraryConfigurator

Repository files navigation

Autofac.Extras.EnterpriseLibraryConfigurator

Microsoft Patterns and Practices Enterprise Library 5 support for using Autofac as the container.

Build status

⚠️ MAINTENANCE MODE: This package is in maintenance-only mode. Bug fixes may be addressed and Autofac compatibility may be checked but no new features will be added.

The Autofac.Extras.EnterpriseLibraryConfigurator package provides a way to use Autofac as the backing store for dependency injection in Microsoft Enterprise Library 5 instead of using Unity. It does this in conjunction with the Autofac Common Service Locator implementation.

⚠️ In Enterprise Library 6, Microsoft removed the tightly-coupled dependency resolution mechanisms from the application blocks so there's no more need for this configurator past Enterprise Library 5.

Using the Configurator

The simplest way to use the configurator is to set up your Enterprise Library configuration in your app.config or web.config and use the RegisterEnterpriseLibrary() extension. This extension parses the configuration and performs the necessary registrations. You then need to set the ``nterpriseLibraryContainer.Currentto use anAutofacServiceLocator` from the Autofac Common Service Locator implementation.

var builder = new ContainerBuilder();
builder.RegisterEnterpriseLibrary();
var container = builder.Build();
var csl = new AutofacServiceLocator(container);
EnterpriseLibraryContainer.Current = csl;

Specifying a Registration Source

The RegisterEnterpriseLibrary() extension does allow you to specify your own IConfigurationSource so if your configuration is not in app.config or web.config you can still use Autofac.

var config = GetYourConfigurationSource();
var builder = new ContainerBuilder();
builder.RegisterEnterpriseLibrary(config);
var container = builder.Build();
var csl = new AutofacServiceLocator(container);
EnterpriseLibraryContainer.Current = csl;

Example

There is an example project showing Enterprise Library 5 configuration along with the Exception Handling Block in the Autofac examples repository.

About

Microsoft Patterns and Practices Enterprise Library 5 support for using Autofac as the container.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages