ContainerRegisterCollectionTService Method (IEnumerableTService)

Simple Injector

Note: This API is now obsolete.

Registers a dynamic (container-uncontrolled) collection of elements of type TService. A call to GetAllInstancesTService will return the containerUncontrolledCollection itself, and updates to the collection will be reflected in the result. If updates are allowed, make sure the collection can be iterated safely if you're running a multi-threaded application.

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

[ObsoleteAttribute("Please use Container.Collection.Register instead. Will be removed in version 6.0.", 
	true)]
public void RegisterCollection<TService>(
	IEnumerable<TService> containerUncontrolledCollection
)
where TService : class

Parameters

containerUncontrolledCollection
Type: System.Collections.GenericIEnumerableTService
The container-uncontrolled collection to register.

Type Parameters

TService
The interface or base type that can be used to retrieve instances.
Exceptions

ExceptionCondition
InvalidOperationException Thrown when this container instance is locked and can not be altered, or when a containerUncontrolledCollection for TService has already been registered.
ArgumentNullException Thrown when containerUncontrolledCollection is a null reference.
See Also

Reference