ContainerCollectionRegistratorRegisterTService Method (IEnumerableAssembly, Lifestyle)

Simple Injector
Registers all concrete, non-generic types (both public and internal) that are defined in the given set of assemblies and that implement the given TService with the supplied lifestyle and register them as a collection of TService. Unless overridden using a custom LifestyleSelectionBehavior, the default lifestyle is Transient.

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

public void Register<TService>(
	IEnumerable<Assembly> assemblies,
	Lifestyle lifestyle
where TService : class


Type: System.Collections.GenericIEnumerableAssembly
A list of assemblies that will be searched.
Type: SimpleInjectorLifestyle
The lifestyle to register instances with.

Type Parameters

The element type of the collections to register. This can be either a non-generic, closed-generic or open-generic type.

ArgumentNullExceptionThrown when one of the supplied arguments contain a null reference.

Note that this overload only allows all registered types to have same lifestyle. In case you need individual elements to have a different lifestyle, please use GetTypesToRegisterTService(Assembly) to retrieve the TService implementations and than either call Append(Type, Type, Lifestyle) on each individual type, or convert the collection of types into a collection of Registration instances (by calling CreateRegistration(Type, Container)) and register that collection using Register(Type, IEnumerableRegistration).
See Also