Table of Contents

Class TypeExtensions

Namespace
PAC.Extensions
public static class TypeExtensions
Inheritance
TypeExtensions
Inherited Members

Methods

GetTypeOfRawGenericSuperclass(Type, Type)

Gets the concrete version of the given raw generic type that 'subType' inherits - e.g. List<int> inherits from the raw generic IEnumerable<>, with the concrete type returned by this method being IEnumerable<int>.

Throws an exception if 'rawGeneric' is not a raw generic. For example, List<> is a raw generic, but List<int> is not.

Throws an exception if 'subType' does not inherit from 'rawGeneric'.

public static Type GetTypeOfRawGenericSuperclass(this Type subType, Type rawGeneric)

Parameters

subType Type
rawGeneric Type

Returns

Type

IsAutoProperty(PropertyInfo)

Determines if the given property is an auto property - i.e. it has both a getter and setter with no body, for example

public string name { get; set; }
public static bool IsAutoProperty(this PropertyInfo property)

Parameters

property PropertyInfo

Returns

bool

IsGenericList(Type)

Determines if the given type is List<T> for some type T.

public static bool IsGenericList(this Type type)

Parameters

type Type

Returns

bool

IsRawGeneric(Type)

Determines if the given type is a raw generic - e.g. List<> is a raw generic, but List<int> is not. Also returns false for non-generic types.

public static bool IsRawGeneric(this Type type)

Parameters

type Type

Returns

bool

IsStruct(Type)

Determiens if the given type is a struct or not.

public static bool IsStruct(this Type type)

Parameters

type Type

Returns

bool

IsSubclassOfRawGeneric(Type, Type)

Determines if the given type inherits from the given some concrete version of the given raw generic type - e.g. List<int> inherits from the raw generic IEnumerable<>.

Throws an exception if 'rawGeneric' is not a raw generic. For example, List<> is a raw generic, but List<int> is not.

public static bool IsSubclassOfRawGeneric(this Type subType, Type rawGeneric)

Parameters

subType Type
rawGeneric Type

Returns

bool