Table of Contents

Class TypeHelper

Namespace
Dynamicweb.Extensibility
Assembly
Dynamicweb.Core.dll
public static class TypeHelper
Inheritance
TypeHelper
Inherited Members

Methods

GetCustomAttribute<T>(MemberInfo)

public static T? GetCustomAttribute<T>(MemberInfo member) where T : Attribute

Parameters

member MemberInfo

Returns

T

Type Parameters

T

GetCustomAttribute<T>(MemberInfo, bool)

public static T? GetCustomAttribute<T>(MemberInfo member, bool inherit) where T : Attribute

Parameters

member MemberInfo
inherit bool

Returns

T

Type Parameters

T

GetCustomAttributes<T>(MemberInfo)

public static IEnumerable<T> GetCustomAttributes<T>(MemberInfo member) where T : Attribute

Parameters

member MemberInfo

Returns

IEnumerable<T>

Type Parameters

T

GetCustomAttributes<T>(MemberInfo, bool)

public static IEnumerable<T> GetCustomAttributes<T>(MemberInfo member, bool inherit) where T : Attribute

Parameters

member MemberInfo
inherit bool

Returns

IEnumerable<T>

Type Parameters

T

GetGenericTypeArguments(Type, Type)

public static Type[] GetGenericTypeArguments(Type type, Type baseType)

Parameters

type Type
baseType Type

Returns

Type[]

GetProperty(Type, string)

public static PropertyInfo? GetProperty(Type type, string propertyName)

Parameters

type Type
propertyName string

Returns

PropertyInfo

GetPropertyFromExpression(Expression)

public static PropertyInfo? GetPropertyFromExpression(Expression expression)

Parameters

expression Expression

Returns

PropertyInfo

GetPropertyValue(object, string)

public static object? GetPropertyValue(object instance, string propertyName)

Parameters

instance object
propertyName string

Returns

object

GetTypeNameWithAssembly(Type)

Get name of the type in format "[FullName], [AssemblyName]"

public static string GetTypeNameWithAssembly(Type type)

Parameters

type Type

Returns

string

GetTypeNameWithoutAssembly(string)

public static string GetTypeNameWithoutAssembly(string typeName)

Parameters

typeName string

Returns

string

HasCustomAttribute<T>(MemberInfo)

public static bool HasCustomAttribute<T>(MemberInfo member) where T : Attribute

Parameters

member MemberInfo

Returns

bool

Type Parameters

T

InvokeMethod(object, string, object?[]?)

Invokes the method of the specfied name on the specified instance with the specified parameters.

public static object? InvokeMethod(object instance, string methodName, object?[]? arguments)

Parameters

instance object

The instance.

methodName string

Name of the method.

arguments object[]

The arguments.

Returns

object

InvokeStaticGenericMethod<T>(Type, Type, string, params object?[])

Invokes a static method on the given generic type.

public static T? InvokeStaticGenericMethod<T>(Type type, Type genericType, string methodName, params object?[] arguments)

Parameters

type Type

The type.

genericType Type

The generic type.

methodName string

Name of method.

arguments object[]

The arguments.

Returns

T

Type Parameters

T

Type of returned result.

InvokeStaticMethod(Type, string, object?[]?)

Invokes a static method on the given type. The method must be static and public. The params array must contain elements that exactly match a signature for given method.

public static object? InvokeStaticMethod(Type type, string methodName, object?[]? arguments)

Parameters

type Type

The type.

methodName string

Name of the function.

arguments object[]

The arguments.

Returns

object

IsDerivedFrom(Type, Type, params Type[])

public static bool IsDerivedFrom(Type type, Type baseType, params Type[] genericTypeParameters)

Parameters

type Type
baseType Type
genericTypeParameters Type[]

Returns

bool

IsDerivedFrom<TBase>(Type, params Type[])

public static bool IsDerivedFrom<TBase>(Type type, params Type[] genericTypeParameters)

Parameters

type Type
genericTypeParameters Type[]

Returns

bool

Type Parameters

TBase

IsTypeNameWithAssembly(string)

public static bool IsTypeNameWithAssembly(string typeName)

Parameters

typeName string

Returns

bool

SetPropertyValue(object, string, object?)

public static void SetPropertyValue(object instance, string propertyName, object? propertyValue)

Parameters

instance object
propertyName string
propertyValue object

TryGetProperty(Type, string, out PropertyInfo?)

public static bool TryGetProperty(Type type, string propertyName, out PropertyInfo? property)

Parameters

type Type
propertyName string
property PropertyInfo

Returns

bool

TryGetPropertyValue(object?, string?, out object?)

public static bool TryGetPropertyValue(object? instance, string? propertyName, out object? value)

Parameters

instance object
propertyName string
value object

Returns

bool

TryInvokeMethod(object, string, object?[]?, out object?)

public static bool TryInvokeMethod(object instance, string methodName, object?[]? arguments, out object? value)

Parameters

instance object
methodName string
arguments object[]
value object

Returns

bool

TryInvokeStaticMethod(Type, string, object?[]?, out object?)

public static bool TryInvokeStaticMethod(Type type, string methodName, object?[]? arguments, out object? value)

Parameters

type Type
methodName string
arguments object[]
value object

Returns

bool

TrySetPropertyValue(object, string, object?)

public static bool TrySetPropertyValue(object instance, string propertyName, object? value)

Parameters

instance object
propertyName string
value object

Returns

bool
To top