Click or drag to resize

EnterpriseLibraryRegistrationExtensions Class

Extension methods that assist in adding Enterprise Library type registrations to an Autofac container.
Inheritance Hierarchy

Namespace:  Autofac.Extras.EnterpriseLibraryConfigurator
Assembly:  Autofac.Extras.EnterpriseLibraryConfigurator (in Autofac.Extras.EnterpriseLibraryConfigurator.dll) Version: 4.0.0-CI-216
public static class EnterpriseLibraryRegistrationExtensions

The EnterpriseLibraryRegistrationExtensions type exposes the following members.

Public methodStatic memberCode exampleRegisterEnterpriseLibrary(ContainerBuilder)
Adds dependency registrations from the default Enterprise Library configuration source to the provided Autofac container builder.
Public methodStatic memberCode exampleRegisterEnterpriseLibrary(ContainerBuilder, IConfigurationSource)
Adds dependency registrations from a specified Enterprise Library configuration source to the provided Autofac container builder.
Public methodStatic memberCode exampleRegisterTypeRegistration
Registers an Enterprise Library type registration with Autofac.
Public methodStatic memberCode exampleUsingConstructorFromTLimit, TReflectionActivatorData, TStyle
Sets a constructor preference on an Autofac registration based on the constructor information in an Enterprise Library type registration.
Public methodStatic memberWithInstanceScopeTLimit, TActivatorData, TRegistrationStyle
Sets an object registration to the Autofac equivalent of the provided Enterprise Library instance scope.
Public methodStatic memberCode exampleWithParametersFromTLimit, TReflectionActivatorData, TStyle
Inspects the constructor parameters in an Enterprise Library type registration and applies those to an Autofac service registration.

The Microsoft Patterns and Practices Enterprise Library comes with an abstraction around dependency registration. These extension methods help translate these more general TypeRegistration instances into Autofac-specific registrations.

This is particularly useful in conjunction with the AutofacServiceLocator when you want to use Autofac as the mechanism for resolving Enterprise Library application block dependencies rather than Unity.

The primary Enterprise Library entry point is RegisterEnterpriseLibrary. If you're trying to get Enterprise Library application blocks to use Autofac, start there.


The simplest way to get started with Enterprise Library and Autofac is via RegisterEnterpriseLibrary(ContainerBuilder). While building your Autofac container, use that extension to get the configuration out of the default Enterprise Library configuration location and add the appropriate dependency registrations to your container.

After the container is built, use the AutofacServiceLocator to set the default Enterprise Library container for any internal resolutions it needs to make.

// Create the container and register EntLib configured dependencies.
var builder = new ContainerBuilder();

// Register any other dependencies, then build the container and set
// the default EntLib service locator.
var container = builder.Build();
var autofacLocator = new AutofacServiceLocator(container);
EnterpriseLibraryContainer.Current = autofacLocator;
See Also