Table of Contents

Class TypeExtension

Namespace
Xarial.XToolkit.Reflection
Assembly
BlueByte.SOLIDWORKS.PDMProfessional.SDK.dll
public static class TypeExtension
Inheritance
TypeExtension
Inherited Members

Methods

FindMethod(Type, string, BindingFlags)

public static MethodInfo FindMethod(this Type type, string methodName, BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)

Parameters

type Type
methodName string
flags BindingFlags

Returns

MethodInfo

GetArgumentsOfGenericType(Type, Type)

public static Type[] GetArgumentsOfGenericType(this Type thisType, Type genericType)

Parameters

thisType Type
genericType Type

Returns

Type[]

GetEnumFlags(Type)

public static Enum[] GetEnumFlags(this Type enumType)

Parameters

enumType Type

Returns

Enum[]

GetMethodWithGenericParameters(Type, string, Type[], BindingFlags)

Finds the method from the type if

public static MethodInfo GetMethodWithGenericParameters(this Type type, string name, Type[] paramTypes, BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public)

Parameters

type Type

Type to get method from

name string

Name of the method

paramTypes Type[]

Parameter types of the method

bindingFlags BindingFlags

Binding flags

Returns

MethodInfo

Method or null if not found

Remarks

This method is similar to GetMethod(string), but allowing to specify the generic types definitions

InvokeMethod(object, MethodInfo, params object[])

public static void InvokeMethod(object obj, MethodInfo method, params object[] args)

Parameters

obj object
method MethodInfo
args object[]

InvokeMethod<TRes>(object, MethodInfo, params object[])

public static TRes InvokeMethod<TRes>(object obj, MethodInfo method, params object[] args)

Parameters

obj object
method MethodInfo
args object[]

Returns

TRes

Type Parameters

TRes

IsAssignableToGenericType(Type, Type)

Checks if this type can be assigned to the generic type

public static bool IsAssignableToGenericType(this Type thisType, Type genericType)

Parameters

thisType Type

This type

genericType Type

Generic type

Returns

bool

True if this type can be assigned to generic type

TryFindGenericType(Type, Type)

public static Type TryFindGenericType(this Type thisType, Type genericType)

Parameters

thisType Type
genericType Type

Returns

Type

TryGetAttribute<TAtt>(Type, out TAtt, bool)

public static bool TryGetAttribute<TAtt>(this Type type, out TAtt att, bool searchInParentTypes = false) where TAtt : Attribute

Parameters

type Type
att TAtt
searchInParentTypes bool

Returns

bool

Type Parameters

TAtt