TypeLoader Class
Definition
Section titled “Definition”Provides methods for loading specified types from an assembly.
public static class TypeLoaderInheritance object
Fields
Section titled “Fields”CecilResolver
Section titled “CecilResolver”Default assembly resolved used by the TypeLoader
public static readonly DefaultAssemblyResolver CecilResolverReaderParameters
Section titled “ReaderParameters”Default reader parameters used by TypeLoader
public static readonly ReaderParameters ReaderParametersSearchDirectories
Section titled “SearchDirectories”public static HashSet<string> SearchDirectoriesMethods
Section titled “Methods”CecilResolveOnFailure(object, AssemblyNameReference)
Section titled “CecilResolveOnFailure(object, AssemblyNameReference)”public static AssemblyDefinition CecilResolveOnFailure(object sender, AssemblyNameReference reference)Parameters
Section titled “Parameters”sender object
reference AssemblyNameReference
Returns
Section titled “Returns”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.
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()Parameters
Section titled “Parameters”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.
Returns
Section titled “Returns”Dictionary<string, List<T>>
A dictionary of all assemblies in the directory and the list of type metadatas of types that match the selector.
LoadAssemblyCache(string)
Section titled “LoadAssemblyCache(string)”Loads an index of type metadatas from a cache.
public static Dictionary<string, CachedAssembly<T>> LoadAssemblyCache<T>(string cacheName) where T : ICacheable, new()Parameters
Section titled “Parameters”cacheName string
Name of the cache
Returns
Section titled “Returns”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.
public static void SaveAssemblyCache<T>(string cacheName, Dictionary<string, List<T>> entries, Dictionary<string, string> hashes) where T : ICacheableParameters
Section titled “Parameters”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.
public static string TypeLoadExceptionToString(ReflectionTypeLoadException ex)Parameters
Section titled “Parameters”ex ReflectionTypeLoadException
TypeLoadException
Returns
Section titled “Returns”string
Readable representation of the exception
Events
Section titled “Events”AssemblyResolve
Section titled “AssemblyResolve”Event fired when TypeLoader fails to resolve a type during type loading.
public static event AssemblyResolveEventHandler AssemblyResolve