Registers the specified delegate that allows returning transient instances of
TService. The delegate is expected to always return a new instance on
each call.
Namespace: SimpleInjector
Assembly: SimpleInjector (in SimpleInjector.dll) Version: 5.3.0
Syntax
public void Register<TService>( Func<TService> instanceCreator ) where TService : class
Parameters
- instanceCreator
- Type: SystemFuncTService
The delegate that allows building or creating new instances.
Type Parameters
- TService
- The interface or base type that can be used to retrieve instances.
Exceptions
Exception | Condition |
---|---|
InvalidOperationException | Thrown when this container instance is locked and can not be altered, or when the TService has already been registered. |
ArgumentNullException | Thrown when instanceCreator is a null reference. |
Remarks
See Also