Returns all concrete non-generic types that are located in the supplied assemblies
and implement or inherit from the supplied serviceType.
serviceType can be an open-generic type.
Namespace: SimpleInjector
Assembly: SimpleInjector (in SimpleInjector.dll) Version: 5.3.0
Syntax
public IEnumerable<Type> GetTypesToRegister( Type serviceType, IEnumerable<Assembly> assemblies )
Parameters
- serviceType
- Type: SystemType
The base type or interface to find derived types for. This can be both a non-generic and open-generic type. - assemblies
- Type: System.Collections.GenericIEnumerableAssembly
A list of assemblies that will be searched.
Return Value
Type: IEnumerableTypeA collection of types.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | Thrown when one of the arguments contain a null reference. |
Remarks
C#
var container = new Container(); var assemblies = new[] { typeof(ICommandHandler<>).Assembly }; var types = container.GetTypesToRegister(typeof(ICommandHandler<>), assemblies) .Where(type => type.IsPublic); container.Register(typeof(ICommandHandler<>), types);
See Also