ContainerGetTypesToRegisterTService Method (IEnumerableAssembly, TypesToRegisterOptions)

Simple Injector
Returns all concrete types that are located in the supplied assemblies and implement or inherit from the supplied TService and match the specified options...

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

public IEnumerable<Type> GetTypesToRegister<TService>(
	IEnumerable<Assembly> assemblies,
	TypesToRegisterOptions options


Type: System.Collections.GenericIEnumerableAssembly
A list of assemblies that will be searched.
Type: SimpleInjectorTypesToRegisterOptions
The options.

Type Parameters

The base type or interface to find derived types for.

Return Value

Type: IEnumerableType
A collection of types.

ArgumentNullExceptionThrown when one of the arguments contain a null reference.

Use this method when you need influence the types that are registered using Register. The Register overloads that take a collection of Assembly objects use this method internally to get the list of types that need to be registered. Instead of calling such overload, you can call an overload that takes a list of Type objects and pass in a filtered result from this GetTypesToRegister method.
var container = new Container();

var assemblies = new[] { typeof(FileLogger).Assembly };
var options = new TypesToRegisterOptions { IncludeGenericTypeDefinitions: true };
var types = container.GetTypesToRegister<ILogger>(assemblies, options)
    .Where(t => t.IsPublic);

This example calls the GetTypesToRegister method to request a list of concrete implementations of the ILogger interface from the assembly of that interface. After that all internal types are filtered out. This list is supplied to the Collection.Register<TService>((IEnumerable<Type>) overload to finish the registration.
See Also