Registers the specified delegate that allows constructing a single serviceType
instance. The container will call this delegate at most once during the lifetime of the application.
Namespace: SimpleInjector
Assembly: SimpleInjector (in SimpleInjector.dll) Version: 5.3.0
Syntax
Parameters
- serviceType
- Type: SystemType
The base type or interface to register. - instanceCreator
- Type: SystemFuncObject
The delegate that will be used for creating that single instance.
Exceptions
| Exception | Condition |
|---|---|
| ArgumentException | Thrown when serviceType represents an open generic type. |
| ArgumentNullException | Thrown when either serviceType or instanceCreator are null references. |
| InvalidOperationException | Thrown when this container instance is locked and can not be altered, or when an the serviceType has already been registered. |
See Also