ContainerRegister Method (Type, FuncObject, Lifestyle)

Simple Injector
Registers the specified delegate instanceCreator that will produce instances of type serviceType and will be returned when an instance of type serviceType is requested. The delegate is expected to produce new instances on each call. The instances are cached according to the supplied lifestyle.

Namespace:  SimpleInjector
Assembly:  SimpleInjector (in SimpleInjector.dll) Version: 5.3.0
Syntax

public void Register(
	Type serviceType,
	Func<Object> instanceCreator,
	Lifestyle lifestyle
)

Parameters

serviceType
Type: SystemType
The interface or base type that can be used to retrieve instances.
instanceCreator
Type: SystemFuncObject
The delegate that allows building or creating new instances.
lifestyle
Type: SimpleInjectorLifestyle
The lifestyle that specifies how the returned instance will be cached.
Exceptions

ExceptionCondition
InvalidOperationException Thrown when this container instance is locked and can not be altered, or when the serviceType has already been registered.
ArgumentNullException Thrown when one of the supplied arguments is a null reference.
See Also

Reference