Class TypeLocator
Type locator. Find implementation of a given interface across loaded assemblies.
public sealed class TypeLocator
- Inheritance
-
TypeLocator
- Inherited Members
Constructors
TypeLocator(AssemblyLoadContext)
Initializes a new instance of the TypeLocator class.
public TypeLocator(AssemblyLoadContext loadContext)
Parameters
loadContext
AssemblyLoadContextThe load context to search assemblies.
Properties
Default
Gets a singleton instance that use the default AssemblyLoadContext.
public static TypeLocator Default { get; }
Property Value
Remarks
It initializes the type if needed on the first call.
LoadContext
Gets the assembly load context containing the assemblies to scan.
public AssemblyLoadContext LoadContext { get; }
Property Value
Remarks
Use the returned instance to load new assemblies.
Methods
FindImplementationsOf(Type)
Finds and returns a collection of types that implements the given base type across all the loaded assemblies.
public IEnumerable<TypeImplementationInfo> FindImplementationsOf(Type baseType)
Parameters
baseType
TypeThe base type to find implementors.
Returns
- IEnumerable<TypeImplementationInfo>
A collection of types implementing the base type.
FindImplementationsOf(Type, Assembly)
Finds and returns a collection of types that implements the given base type in the assembly.
public IEnumerable<TypeImplementationInfo> FindImplementationsOf(Type baseType, Assembly assembly)
Parameters
Returns
- IEnumerable<TypeImplementationInfo>
A collection of types implementing the base type.
FindImplementationsOfGeneric(Type)
Finds and returns a collection of types that implements the given generic interface across all the loaded assemblies.
public IEnumerable<GenericTypeImplementationInfo> FindImplementationsOfGeneric(Type baseType)
Parameters
baseType
TypeThe generic interface type to find implementors.
Returns
- IEnumerable<GenericTypeImplementationInfo>
A collection of types implementing the interface.
Remarks
The list may contain several times the same if it implements the same interface multiple types with different generic types.
FindImplementationsOfGeneric(Type, Assembly)
Finds and returns a collection of types that implements the given generic type in the assembly.
public IEnumerable<GenericTypeImplementationInfo> FindImplementationsOfGeneric(Type baseType, Assembly assembly)
Parameters
Returns
- IEnumerable<GenericTypeImplementationInfo>
A collection of types implementing the base type.
Remarks
The list may contain several entries for the same implementation type if it implements several type the generic with different parameters.