Skip to content

TypeLoader Class

Provides methods for loading specified types from an assembly.

C#
public static class TypeLoader

Inheritance object

Default assembly resolved used by the TypeLoader

C#
public static readonly DefaultAssemblyResolver CecilResolver

Default reader parameters used by TypeLoader

C#
public static readonly ReaderParameters ReaderParameters
C#
public static HashSet<string> SearchDirectories

CecilResolveOnFailure(object, AssemblyNameReference)

Section titled “CecilResolveOnFailure(object, AssemblyNameReference)”
C#
public static AssemblyDefinition CecilResolveOnFailure(object sender, AssemblyNameReference reference)

sender object

reference AssemblyNameReference

AssemblyDefinition

FindPluginTypes(string, Func<TypeDefinition, string, T>, Func<AssemblyDefinition, bool>, string)

Section titled “FindPluginTypes(string, Func<TypeDefinition, string, T>, Func<AssemblyDefinition, bool>, string)”

Looks up assemblies in the given directory and locates all types that can be loaded and collects their metadata.

C#
public static Dictionary<string, List<T>> FindPluginTypes<T>(string directory, Func<TypeDefinition, string, T> typeSelector, Func<AssemblyDefinition, bool> assemblyFilter = null, string cacheName = null) where T : ICacheable, new()

directory string
The directory to search for assemblies.

typeSelector Func<TypeDefinition, string, T>
A function to check if a type should be selected and to build the type metadata.

assemblyFilter Func<AssemblyDefinition, bool>
A filter function to quickly determine if the assembly can be loaded.

cacheName string
The name of the cache to get cached types from.

Dictionary<string, List<T>>
A dictionary of all assemblies in the directory and the list of type metadatas of types that match the selector.

Loads an index of type metadatas from a cache.

C#
public static Dictionary<string, CachedAssembly<T>> LoadAssemblyCache<T>(string cacheName) where T : ICacheable, new()

cacheName string
Name of the cache

Dictionary<string, CachedAssembly<T>>
Cached type metadatas indexed by the path of the assembly that defines the type. If no cache is defined, return null.

SaveAssemblyCache(string, Dictionary<string, List>, Dictionary<string, string>)

Section titled “SaveAssemblyCache(string, Dictionary<string, List>, Dictionary<string, string>)”

Saves indexed type metadata into a cache.

C#
public static void SaveAssemblyCache<T>(string cacheName, Dictionary<string, List<T>> entries, Dictionary<string, string> hashes) where T : ICacheable

cacheName string
Name of the cache

entries Dictionary<string, List<T>>
List of plugin metadatas indexed by the path to the assembly that contains the types

hashes Dictionary<string, string>
Hash values that can be used for checking similarity between cached and live assembly

TypeLoadExceptionToString(ReflectionTypeLoadException)

Section titled “TypeLoadExceptionToString(ReflectionTypeLoadException)”

Converts TypeLoadException to a readable string.

C#
public static string TypeLoadExceptionToString(ReflectionTypeLoadException ex)

ex ReflectionTypeLoadException
TypeLoadException

string
Readable representation of the exception

Event fired when TypeLoader fails to resolve a type during type loading.

C#
public static event AssemblyResolveEventHandler AssemblyResolve

AssemblyResolveEventHandler