C# Class Catel.Reflection.TypeCache

Cache containing the types of an appdomain.
显示文件 Open project: Catel/Catel

Public Methods

Method Description
GetType ( string typeNameWithAssembly, bool ignoreCase = false ) : Type

Gets the specified type from the loaded assemblies.

GetTypeWithAssembly ( string typeName, string assemblyName, bool ignoreCase = false ) : Type

Gets the specified type from the loaded assemblies.

GetTypeWithoutAssembly ( string typeNameWithoutAssembly, bool ignoreCase = false ) : Type

Gets the type without assembly. For example, when the value Catel.TypeHelper is used as parameter, the type for Catel.TypeHelper, Catel.Core will be returned.

Note that this method can only support one type of "simple type name" resolving. For example, if "Catel.TypeHelper" is located in multiple assemblies, it will always use the latest known type for resolving the type.

GetTypes ( bool>.Func predicate = null ) : System.Type[]

Gets all the types from the current AppDomain where the predicate returns true.

GetTypesImplementingInterface ( Type interfaceType ) : System.Type[]

Gets the types implementing the specified interface.

GetTypesOfAssembly ( Assembly assembly, bool>.Func predicate = null ) : System.Type[]

Gets the types of the specified assembly.

InitializeTypes ( Assembly assembly = null, bool forceFullInitialization = false ) : void

Initializes the types in the specified assembly. It does this by looping through all loaded assemblies and registering the type by type name and assembly name. The types initialized by this method are used by object.GetType.

InitializeTypes ( bool forceFullInitialization, string assemblyName ) : void

Initializes the types. It does this by looping through all loaded assemblies and registering the type by type name and assembly name. The types initialized by this method are used by object.GetType.

Private Methods

Method Description
GetAssemblyTypes ( List assemblies ) : HashSet>.Dictionary
GetType ( string typeName, string assemblyName, bool ignoreCase ) : Type

Gets the type.

GetTypeBySplittingInternals ( string typeWithInnerTypes ) : Type

Gets the type by splitting internal types. This means that System.Collections.List`1[[MyCustomType.Item]] will be splitted and resolved separately.

GetTypesPrefilteredByAssembly ( string assemblyName, bool>.Func predicate ) : System.Type[]

Gets the types prefiltered by assembly. If types must be retrieved from a single assembly only, this method is very fast.

InitializeAssemblies ( IEnumerable assemblies, bool force ) : void
InitializeType ( Assembly assembly, Type type ) : void
InitializeTypes ( bool forceFullInitialization, Assembly assembly = null ) : void
OnAssemblyLoaded ( object sender, AssemblyLoadEventArgs args ) : void

Called when an assembly is loaded in the current AppDomain.

ShouldIgnoreAssembly ( Assembly assembly ) : bool

Determines whether the specified assembly must be ignored by the type cache.

ShouldIgnoreType ( Assembly assembly, Type type ) : bool

Determines whether the specified type must be ignored by the type cache.

TypeCache ( ) : System

Method Details

GetType() public static method

Gets the specified type from the loaded assemblies.
The is null or whitespace.
public static GetType ( string typeNameWithAssembly, bool ignoreCase = false ) : Type
typeNameWithAssembly string The name of the type including namespace and assembly, formatted with the method.
ignoreCase bool A value indicating whether the case should be ignored.
return System.Type

GetTypeWithAssembly() public static method

Gets the specified type from the loaded assemblies.
The is null or whitespace. The is null or whitespace.
public static GetTypeWithAssembly ( string typeName, string assemblyName, bool ignoreCase = false ) : Type
typeName string The name of the type including namespace.
assemblyName string The name of the type including namespace.
ignoreCase bool A value indicating whether the case should be ignored.
return System.Type

GetTypeWithoutAssembly() public static method

Gets the type without assembly. For example, when the value Catel.TypeHelper is used as parameter, the type for Catel.TypeHelper, Catel.Core will be returned.
Note that this method can only support one type of "simple type name" resolving. For example, if "Catel.TypeHelper" is located in multiple assemblies, it will always use the latest known type for resolving the type.
The is null or whitespace.
public static GetTypeWithoutAssembly ( string typeNameWithoutAssembly, bool ignoreCase = false ) : Type
typeNameWithoutAssembly string The type name without assembly.
ignoreCase bool A value indicating whether the case should be ignored.
return System.Type

GetTypes() public static method

Gets all the types from the current AppDomain where the predicate returns true.
The is null.
public static GetTypes ( bool>.Func predicate = null ) : System.Type[]
predicate bool>.Func The predicate where the type should apply to.
return System.Type[]

GetTypesImplementingInterface() public static method

Gets the types implementing the specified interface.
public static GetTypesImplementingInterface ( Type interfaceType ) : System.Type[]
interfaceType System.Type Type of the interface.
return System.Type[]

GetTypesOfAssembly() public static method

Gets the types of the specified assembly.
public static GetTypesOfAssembly ( Assembly assembly, bool>.Func predicate = null ) : System.Type[]
assembly System.Reflection.Assembly The assembly.
predicate bool>.Func The predicate to use on the types.
return System.Type[]

InitializeTypes() public static method

Initializes the types in the specified assembly. It does this by looping through all loaded assemblies and registering the type by type name and assembly name. The types initialized by this method are used by object.GetType.
public static InitializeTypes ( Assembly assembly = null, bool forceFullInitialization = false ) : void
assembly System.Reflection.Assembly The assembly to initialize the types from. If null, all assemblies will be checked.
forceFullInitialization bool If true, the types are initialized, even when the types are already initialized.
return void

InitializeTypes() public static method

Initializes the types. It does this by looping through all loaded assemblies and registering the type by type name and assembly name. The types initialized by this method are used by object.GetType.
The is null or whitespace.
public static InitializeTypes ( bool forceFullInitialization, string assemblyName ) : void
forceFullInitialization bool If true, the types are initialized, even when the types are already initialized.
assemblyName string Name of the assembly. If null, all assemblies will be checked.
return void