Class TypeInfoExtensions
Extension methods for type information.
Inheritance
Inherited Members
Namespace: Kephas.Reflection
Assembly: Kephas.Core.dll
Syntax
public static class TypeInfoExtensions
Methods
| Improve this Doc View SourceAsRuntimeTypeInfo(TypeInfo)
Gets the IRuntimeTypeInfo for the provided System.Reflection.TypeInfo instance.
Declaration
public static IRuntimeTypeInfo AsRuntimeTypeInfo(this TypeInfo typeInfo)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.TypeInfo | typeInfo | The type information instance. |
Returns
Type | Description |
---|---|
IRuntimeTypeInfo | The provided System.Reflection.TypeInfo's associated IRuntimeTypeInfo. |
AsType(ITypeInfo)
Gets the System.Type for the provided ITypeInfo instance.
Declaration
public static Type AsType(this ITypeInfo typeInfo)
Parameters
Type | Name | Description |
---|---|---|
ITypeInfo | typeInfo | The type information instance. |
Returns
Type | Description |
---|---|
System.Type | The provided ITypeInfo's associated System.Type. |
GetBaseConstructedGenericOf(TypeInfo, TypeInfo)
A TypeInfo extension method that gets the base constructed generic of a provided type. The base can be either an interface or a class.
Declaration
public static TypeInfo GetBaseConstructedGenericOf(this TypeInfo typeInfo, TypeInfo openGenericTypeInfo)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.TypeInfo | typeInfo | The type to act on. |
System.Reflection.TypeInfo | openGenericTypeInfo | The open generic type of which constructed generic type is requested. |
Returns
Type | Description |
---|---|
System.Reflection.TypeInfo | The base constructed generic. |
Examples
var type = typeof(string).GetTypeInfo().GetBaseConstructedGenericOf(typeof(IEnumerable<>).GetTypeInfo()); Assert.AreSame(type, typeof(IEnumerable<char>).GetTypeInfo());
| Improve this Doc View SourceGetDeclaredMembers(ITypeInfo)
Gets the model element's own members, excluding those declared by the base element or mixins.
Declaration
public static IEnumerable<IElementInfo> GetDeclaredMembers(this ITypeInfo typeInfo)
Parameters
Type | Name | Description |
---|---|---|
ITypeInfo | typeInfo | The type information. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IElementInfo> | The members declared exclusively at the type level. |
GetNonNullableType(TypeInfo)
Gets the type wrapped by the System.Nullable<T> or, if the type is not a nullable type, the type itself.
Declaration
public static TypeInfo GetNonNullableType(this TypeInfo typeInfo)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.TypeInfo | typeInfo | The type to be checked. |
Returns
Type | Description |
---|---|
System.Reflection.TypeInfo | A System.Type instance. |
GetQualifiedFullName(TypeInfo, Boolean)
Gets the qualified full name of a System.Reflection.TypeInfo. Optionally, strips away the version information.
Declaration
public static string GetQualifiedFullName(this TypeInfo typeInfo, bool stripVersionInfo = true)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.TypeInfo | typeInfo | The type information instance. |
System.Boolean | stripVersionInfo |
|
Returns
Type | Description |
---|---|
System.String | The qualified full name. |
IsConstructedGenericType(ITypeInfo)
Indicates whether the ITypeInfo is a generic type definition (aka open generic).
Declaration
public static bool IsConstructedGenericType(this ITypeInfo typeInfo)
Parameters
Type | Name | Description |
---|---|---|
ITypeInfo | typeInfo | The type information instance. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsGenericType(ITypeInfo)
Indicates whether the ITypeInfo is a generic type.
Declaration
public static bool IsGenericType(this ITypeInfo typeInfo)
Parameters
Type | Name | Description |
---|---|---|
ITypeInfo | typeInfo | The type information instance. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsGenericTypeDefinition(ITypeInfo)
Indicates whether the ITypeInfo is a generic type definition (aka open generic).
Declaration
public static bool IsGenericTypeDefinition(this ITypeInfo typeInfo)
Parameters
Type | Name | Description |
---|---|---|
ITypeInfo | typeInfo | The type information instance. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsNullableType(TypeInfo)
Indicates whether the type is an instance of the generic System.Nullable<T> type.
Declaration
public static bool IsNullableType(this TypeInfo typeInfo)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.TypeInfo | typeInfo | The type to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|