Click or drag to resize

AutofacRegistrationPopulate Method (ContainerBuilder, IEnumerableServiceDescriptor, Object)

Populates the Autofac container builder with the set of registered service descriptors and makes IServiceProvider and IServiceScopeFactory available in the container. Using this overload is incompatible with the ASP.NET Core support for IServiceProviderFactory.

Namespace:  Autofac.Extensions.DependencyInjection
Assembly:  Autofac.Extensions.DependencyInjection (in Autofac.Extensions.DependencyInjection.dll) Version: 7.1.0+380b08798bf724f36e200e687129b44a0778ab92
Syntax
public static void Populate(
	this ContainerBuilder builder,
	IEnumerable<ServiceDescriptor> descriptors,
	Object lifetimeScopeTagForSingletons
)

Parameters

builder
Type: AutofacContainerBuilder
The ContainerBuilder into which the registrations should be made.
descriptors
Type: System.Collections.GenericIEnumerableServiceDescriptor
The set of service descriptors to register in the container.
lifetimeScopeTagForSingletons
Type: SystemObject
If provided and not then all registrations with lifetime Singleton are registered using InstancePerMatchingLifetimeScope(Object) with provided lifetimeScopeTagForSingletons instead of using SingleInstance.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ContainerBuilder. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks

Specifying a lifetimeScopeTagForSingletons addresses a specific case where you have an application that uses Autofac but where you need to isolate a set of services in a child scope. For example, if you have a large application that self-hosts ASP.NET Core items, you may want to isolate the ASP.NET Core registrations in a child lifetime scope so they don't show up for the rest of the application. This overload allows that. Note it is the developer's responsibility to execute this and create an AutofacServiceProvider using the child lifetime scope.

See Also