TypeMapper Class
Namespace: PTS.Reflection
Assembly: PTS.Reflection.dll
Provides runtime mapping of relationships between system types.
Syntax
[InitializeOnStart]
public class TypeMapper
Inheritance
Constructors
TypeMapper()
Creates a new instance of the object and initializes reflection indexes.
Declaration
public TypeMapper()
Fields
Static
Static instance accessor.
Declaration
public static readonly TypeMapper Static
Field Value
Type | Description |
---|---|
TypeMapper |
Properties
AssemblyTypes
All system types available in current executon environment.
Declaration
protected HashSet<Type> AssemblyTypes { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.HashSet<System.Type> |
ClassToInterfaceIndex
Associates object types with implemented interfaces.
Declaration
protected IDictionary<Type, ICollection<Type>> ClassToInterfaceIndex { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Type, System.Collections.Generic.ICollection<System.Type>> |
DerivedTypeIndex
Associates object types with types of inherited classes.
Declaration
protected IDictionary<Type, ICollection<Type>> DerivedTypeIndex { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Type, System.Collections.Generic.ICollection<System.Type>> |
InterfacesDirectlyOnTypeIndex
Associates object types with directly implemented interfaces.
Declaration
protected IDictionary<Type, ICollection<Type>> InterfacesDirectlyOnTypeIndex { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Type, System.Collections.Generic.ICollection<System.Type>> |
InterfaceToClassIndex
Associates interface types with implementing object types.
Declaration
protected IDictionary<Type, ICollection<Type>> InterfaceToClassIndex { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Type, System.Collections.Generic.ICollection<System.Type>> |
NameIndex
Associates assembly qualified names with system types.
Declaration
protected IDictionary<string, Type> NameIndex { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Type> |
Types
Gets all types in current execution environment.
Declaration
public IReadOnlyCollection<Type> Types { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyCollection<System.Type> |
TypesImplementingInterfaceDirectlyIndex
Associates interface types with directly implementing object types.
Declaration
protected IDictionary<Type, ICollection<Type>> TypesImplementingInterfaceDirectlyIndex { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Type, System.Collections.Generic.ICollection<System.Type>> |
Methods
DerivedTypesFrom(Type)
Gets types inheriting from specified base type.
Declaration
public ICollection<Type> DerivedTypesFrom(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | Base type to get the inherited types for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.Type> | Collection of types inheriting from speciefied base type. |
GetGenericDefinitionVariant(Type, Int32)
Retrieves generic system type definition with specified number of type parameters.
Declaration
public Type GetGenericDefinitionVariant(Type type, int genericTypeParamCount)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | Generic type definition to get variation with specified number of type arguments for. |
System.Int32 | genericTypeParamCount | Number of generic type parameters of target generic type definition variation. |
Returns
Type | Description |
---|---|
System.Type | Generic type definition of the specified type with specified number of type paramenters if available; otherwise |
GetGenericVariantName(Type, Int32)
Generates assembly qualified name of generic type definition with specified number of type parameters.
Declaration
protected string GetGenericVariantName(Type type, int genericTypeParamCount)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | Generic type definition to get the variant name for. |
System.Int32 | genericTypeParamCount | Number of generic type parameters of target type variant. |
Returns
Type | Description |
---|---|
System.String | Assembly qualified generic type definition name with specified number of type parameters. |
GetType(String)
Retrieves type for given fully qualified descriptor.
Declaration
public Type GetType(string assemblyQualifiedName)
Parameters
Type | Name | Description |
---|---|---|
System.String | assemblyQualifiedName | Fully assembly qualified name of a system type to retrieve. |
Returns
Type | Description |
---|---|
System.Type | System type if found; otherwise |
InterfacesImplementedOnType(Type)
Gets interface types implemented by specified object type.
Declaration
public ICollection<Type> InterfacesImplementedOnType(Type objectType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | objectType | Object type to get the implemented interface types for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.Type> | Collection of interface types implemented by specified type. |
InterfacesImplementedOnTypeDirectly(Type)
Gets interface types implemented by specified type directly. Inherited interfaces are excluded from the collection.
Declaration
public ICollection<Type> InterfacesImplementedOnTypeDirectly(Type objectType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | objectType | Object type to get the directly implemented interface types for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.Type> | Collection of interface types directly implemented by specified type. |
TypesImplementingInterface(Type)
Gets object types that implement specified interface type.
Declaration
public ICollection<Type> TypesImplementingInterface(Type interfaceType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | interfaceType | Interface type to get the implementing object types for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.Type> | Collection of object types that implement the specified interface. |
TypesImplementingInterfaceDirectly(Type)
Gets object types that directly implement specified interface type. Types that implement the interface through inheritance are excluded from the collection.
Declaration
public ICollection<Type> TypesImplementingInterfaceDirectly(Type interfaceType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | interfaceType | Interface type to get the directly implementing object types for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.Type> | Collection of object types that directly implement the specified interface. |
TypesImplementingInterfaces(Type[])
Gets collection of types that implement range of interfaces.
Declaration
public ICollection<Type> TypesImplementingInterfaces(params Type[] interfaces)
Parameters
Type | Name | Description |
---|---|---|
System.Type[] | interfaces | Interfaces the types must implement. |
Returns
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.Type> | Types that implement the specified range of interfaces. |
TypesImplementingInterfacesDirectly(Type[])
Returns collection of object types that directly implement range of interfaces. Inherited object types will not be included.
Declaration
public ICollection<Type> TypesImplementingInterfacesDirectly(params Type[] interfaces)
Parameters
Type | Name | Description |
---|---|---|
System.Type[] | interfaces | Interfaces the types must implement. |
Returns
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.Type> | Object types that directly implement the range of interfaces. |