SimpleInjectorServiceCollectionExtensionsAddSimpleInjector Method

Simple Injector
Sets up the basic configuration that allows Simple Injector to be used in frameworks that require the use of IServiceCollection for registration of framework components. In case of the absense of a DefaultScopedLifestyle, this method will configure AsyncScopedLifestyle as the default scoped lifestyle. In case a setupAction is supplied, that delegate will be called that allow further configuring the container.

Namespace:  SimpleInjector
Assembly:  SimpleInjector.Integration.ServiceCollection (in SimpleInjector.Integration.ServiceCollection.dll) Version: 5.0.0
Syntax

public static IServiceCollection AddSimpleInjector(
	this IServiceCollection services,
	Container container,
	Action<SimpleInjectorAddOptions> setupAction = null
)

Parameters

services
Type: IServiceCollection
The framework's IServiceCollection instance.
container
Type: SimpleInjectorContainer
The application's Container instance.
setupAction (Optional)
Type: SystemActionSimpleInjectorAddOptions
An optional setup action.

Return Value

Type: IServiceCollection
The supplied services.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IServiceCollection. 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
ArgumentNullExceptionThrown when services or container are null references.
See Also

Reference