Registers the specified delegate instanceCreator that will produce instances of type TService and will be returned when an instance of type TService is requested. The delegate is expected to produce new instances on each call. The instances are cached according to the supplied lifestyle.
Assembly: SimpleInjector (in SimpleInjector.dll) Version: 4.2.1
public void Register<TService>( Func<TService> instanceCreator, Lifestyle lifestyle ) where TService : class
Public Sub Register(Of TService As Class) ( instanceCreator As Func(Of TService), lifestyle As Lifestyle )
- Type: SystemFunc
The delegate that allows building or creating new instances.
- Type: SimpleInjectorLifestyle
The lifestyle that specifies how the returned instance will be cached.
- The interface or base type that can be used to retrieve instances.
|InvalidOperationException||Thrown when this container instance is locked and can not be altered, or when the TService has already been registered.|
|ArgumentNullException||Thrown when one of the supplied arguments is a null reference (Nothing in VB).|