Table of Contents

Class TypeLocator

Namespace
Yarhl.Plugins
Assembly
Yarhl.Plugins.dll

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 AssemblyLoadContext

The load context to search assemblies.

Properties

Default

Gets a singleton instance that use the default AssemblyLoadContext.

public static TypeLocator Default { get; }

Property Value

TypeLocator

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

AssemblyLoadContext

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 Type

The 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

baseType Type

The base type to find implementors.

assembly Assembly

The assembly to scan.

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 Type

The 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

baseType Type

The generic type to find implementors.

assembly Assembly

The assembly to scan.

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.