Autofac .NET Inversion of Control Container
Module Class
NamespacesAutofacModule
Base class for user-defined modules. Modules can add a set of releated components to a container (Load(ContainerBuilder)) or attach cross-cutting functionality to other components (AttachToComponentRegistration(IComponentRegistry, IComponentRegistration). Modules are given special support in the XML configuration feature - see http://code.google.com/p/autofac/wiki/StructuringWithModules.
Declaration Syntax
C#Visual BasicVisual C++
public abstract class Module : IModule
Public MustInherit Class Module _
	Implements IModule
public ref class Module abstract : IModule
Members
All MembersConstructorsMethods



IconMemberDescription
Module()()()
Initializes a new instance of the Module class

AttachToComponentRegistration(IComponentRegistry, IComponentRegistration)
Override to attach module-specific functionality to a component registration.

Configure(IComponentRegistry)
Apply the module to the component registry.

Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Finalize()()()
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
GetHashCode()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetType()()()
Gets the Type of the current instance.
(Inherited from Object.)
Load(ContainerBuilder)
Override to add registrations to the container.

MemberwiseClone()()()
Creates a shallow copy of the current Object.
(Inherited from Object.)
ToString()()()
Returns a String that represents the current Object.
(Inherited from Object.)
Remarks
Provides a user-friendly way to implement IModule via ContainerBuilder.
Examples
Defining a module:
CopyC#
public class DataAccessModule : Module
{
    public string ConnectionString { get; set; }

    public override void Load(ContainerBuilder moduleBuilder)
    {
        moduleBuilder.RegisterGeneric(typeof(MyRepository<>))
            .As(typeof(IRepository<>))
            .InstancePerMatchingLifetimeScope(WebLifetime.Request);

        moduleBuilder.Register(c => new MyDbConnection(ConnectionString))
            .As<IDbConnection>()
            .InstancePerMatchingLifetimeScope(WebLifetime.Request);
    }
}
Using the module:
CopyC#
var builder = new ContainerBuilder();
builder.RegisterModule(new DataAccessModule { ConnectionString = "..." });
var container = builder.Build();
var customers = container.Resolve<IRepository<Customer>>();
Inheritance Hierarchy
Object
Module

Assembly: Autofac (Module: Autofac) Version: 2.1.13.813 (2.1.13.813)