ContainerCollectionRegistratorAppendInstance Method (Type, Object)

Simple Injector
Appends a single instance to existing registrations made for a collection of serviceType elements using one of the Container.Collections.Register overloads. This instance must be thread-safe when working in a multi-threaded environment. NOTE: Do note that instances supplied by this method NEVER get disposed by the container, since the instance is assumed to outlive this container instance. If disposing is required, use RegisterSingleton<TService>(Func<TService>).

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

public void AppendInstance(
	Type serviceType,
	Object instance
)

Parameters

serviceType
Type: SystemType
TThe element type of the collections to register.
instance
Type: SystemObject
The instance to register.
Exceptions

ExceptionCondition
ArgumentExceptionThrown when the serviceType is ambiguous, or instance does not implement serviceType.
ArgumentNullExceptionThrown when either serviceType or instance are null references.
See Also

Reference