ContainerRegisterSingleton Method (Type, FuncObject)

Simple Injector
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

public void RegisterSingleton(
	Type serviceType,
	Func<Object> instanceCreator
)

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

ExceptionCondition
ArgumentExceptionThrown when serviceType represents an open generic type.
ArgumentNullExceptionThrown 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

Reference