ContainerRegisterSingleton Method (Type, Object)

Simple Injector

Note: This API is now obsolete.

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: 5.3.0
Syntax

[ObsoleteAttribute("Please use RegisterInstance(Type, object) instead. Will be removed in version 6.0.", 
	true)]
[EditorBrowsableAttribute(EditorBrowsableState.Never)]
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.
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