ContainerRegisterSingleton Method (Type, Object)

Simple Injector
Registers a single instance that will be returned when an instance of type serviceType is requested. This instance must be thread-safe when working in a multi-threaded environment.

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

public void RegisterSingleton(
	Type serviceType,
	Object instance
)

Parameters

serviceType
Type: SystemType
The base type or interface to register.
instance
Type: SystemObject
The instance to register.
Exceptions

ExceptionCondition
ArgumentNullExceptionThrown when either serviceType or instance are null references (Nothing in VB).
ArgumentExceptionThrown when instance is no sub type from serviceType.
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