Click or drag to resize

ServiceProviderExtensionsGetAutofacRoot Method

Tries to cast the instance of ILifetimeScope from AutofacServiceProvider when possible.

Namespace:  Autofac.Extensions.DependencyInjection
Assembly:  Autofac.Extensions.DependencyInjection (in Autofac.Extensions.DependencyInjection.dll) Version: 7.1.0+380b08798bf724f36e200e687129b44a0778ab92
Syntax
public static ILifetimeScope GetAutofacRoot(
	this IServiceProvider serviceProvider
)

Parameters

serviceProvider
Type: SystemIServiceProvider
The instance of IServiceProvider.

Return Value

Type: ILifetimeScope
Returns the instance of ILifetimeScope exposed by AutofacServiceProvider.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IServiceProvider. 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).
Exceptions
ExceptionCondition
InvalidOperationExceptionThrows an InvalidOperationException when instance of IServiceProvider can't be assigned to AutofacServiceProvider.
See Also