ContainerRegisterTService, TImplementation Method (Lifestyle)

Simple Injector
Registers that an instance of TImplementation will be returned when an instance of type TService is requested. The instance is cached according to the supplied lifestyle.

Namespace:  SimpleInjector
Assembly:  SimpleInjector (in SimpleInjector.dll) Version: 4.0.0
Syntax

public void Register<TService, TImplementation>(
	Lifestyle lifestyle
)
where TService : class
where TImplementation : class, TService

Parameters

lifestyle
Type: SimpleInjectorLifestyle
The lifestyle that specifies how the returned instance will be cached.

Type Parameters

TService
The interface or base type that can be used to retrieve the instances.
TImplementation
The concrete type that will be registered.
Exceptions

ExceptionCondition
InvalidOperationException Thrown when this container instance is locked and can not be altered, or when an the TService has already been registered.
ArgumentExceptionThrown when the given TImplementation type is not a type that can be created by the container.
See Also

Reference