Show / Hide Table of Contents

Class TypeInfoExtensions

Extension methods for type information.

Inheritance
System.Object
TypeInfoExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Kephas.Reflection
Assembly: Kephas.Core.dll
Syntax
public static class TypeInfoExtensions

Methods

| Improve this Doc View Source

AsRuntimeTypeInfo(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

GetDeclaredMembers(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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

true to strip away the version information (optional).

Returns
Type Description
System.String

The qualified full name.

| Improve this Doc View Source

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

true if the type is a generic type definition; false if not.

| Improve this Doc View Source

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

true if the type is generic, either closed or open; false if not.

| Improve this Doc View Source

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

true if the type is a generic type definition; false if not.

| Improve this Doc View Source

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

true if the type is nullable; otherwise, false.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX