ContainerRegister Method (Type, Type, Lifestyle)

Simple Injector
Registers that an instance of type implementationType will be returned when an instance of type serviceType is requested. The instance is cached according to the supplied lifestyle. Open and closed generic types are supported.

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

public void Register(
	Type serviceType,
	Type implementationType,
	Lifestyle lifestyle
)

Parameters

serviceType
Type: SystemType
The interface or base type that can be used to retrieve the instances. This can be an open-generic type.
implementationType
Type: SystemType
The concrete type that will be registered. This can be an open-generic type.
lifestyle
Type: SimpleInjectorLifestyle
The lifestyle that specifies how the returned instance will be cached.
Exceptions

ExceptionCondition
ArgumentNullExceptionThrown when one of the supplied arguments is a null reference.
InvalidOperationException Thrown when this container instance is locked and can not be altered, or when the serviceType has already been registered.
ArgumentExceptionThrown when the given implementationType type is not a type that can be created by the container, when either serviceType or implementationType are open generic types, or when serviceType is not assignable from the implementationType.
ArgumentNullExceptionThrown when one of the supplied arguments is a null reference.
See Also

Reference