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
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
Exception | Condition |
---|---|
ArgumentNullException | Thrown when serviceType or implementationType are null references. |
ArgumentException | Thrown 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
See Also