ContainerRegister Method (Type, Type)

Simple Injector
Registers that a new instance of implementationType will be returned every time a serviceType is requested. If serviceType and implementationType represent the same type, the type is registered by itself. 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
)

Parameters

serviceType
Type: SystemType
The base type or interface to register. This can be an open-generic type.
implementationType
Type: SystemType
The actual type that will be returned when requested. This can be an open-generic type.
Exceptions

ExceptionCondition
ArgumentNullExceptionThrown when serviceType or implementationType are null references.
ArgumentExceptionThrown when implementationType is no sub type from serviceType (or the same type).
InvalidOperationException Thrown when this container instance is locked and can not be altered, or when an the serviceType has already been registered.
Remarks

This method uses the container's LifestyleSelectionBehavior to select the exact lifestyle for the specified type. By default this will be Transient.
See Also

Reference