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
memberMemberInfo
Returns
- T
Type Parameters
T
GetCustomAttribute<T>(MemberInfo, bool)
public static T? GetCustomAttribute<T>(MemberInfo member, bool inherit) where T : Attribute
Parameters
memberMemberInfoinheritbool
Returns
- T
Type Parameters
T
GetCustomAttributes<T>(MemberInfo)
public static IEnumerable<T> GetCustomAttributes<T>(MemberInfo member) where T : Attribute
Parameters
memberMemberInfo
Returns
- IEnumerable<T>
Type Parameters
T
GetCustomAttributes<T>(MemberInfo, bool)
public static IEnumerable<T> GetCustomAttributes<T>(MemberInfo member, bool inherit) where T : Attribute
Parameters
memberMemberInfoinheritbool
Returns
- IEnumerable<T>
Type Parameters
T
GetGenericTypeArguments(Type, Type)
public static Type[] GetGenericTypeArguments(Type type, Type baseType)
Parameters
Returns
- Type[]
GetProperty(Type, string)
public static PropertyInfo? GetProperty(Type type, string propertyName)
Parameters
Returns
GetPropertyFromExpression(Expression)
public static PropertyInfo? GetPropertyFromExpression(Expression expression)
Parameters
expressionExpression
Returns
GetPropertyValue(object, string)
public static object? GetPropertyValue(object instance, string propertyName)
Parameters
Returns
GetTypeNameWithAssembly(Type)
Get name of the type in format "[FullName], [AssemblyName]"
public static string GetTypeNameWithAssembly(Type type)
Parameters
typeType
Returns
GetTypeNameWithoutAssembly(string)
public static string GetTypeNameWithoutAssembly(string typeName)
Parameters
typeNamestring
Returns
HasCustomAttribute<T>(MemberInfo)
public static bool HasCustomAttribute<T>(MemberInfo member) where T : Attribute
Parameters
memberMemberInfo
Returns
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
instanceobjectThe instance.
methodNamestringName of the method.
argumentsobject[]The arguments.
Returns
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
typeTypeThe type.
genericTypeTypeThe generic type.
methodNamestringName of method.
argumentsobject[]The arguments.
Returns
- T
Type Parameters
TType 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
Returns
IsDefaultValue(object?, Type)
Determines whether the specified value is the default value for the given type. The default value for a value type is the value produced by the default constructor, while for reference types, the default value is null.
public static bool IsDefaultValue(object? value, Type type)
Parameters
valueobjectThe value to check against the default.
typeTypeThe type to check the default value for. Must not be null.
Returns
- bool
True if the value is the default for the specified type; otherwise, false.
IsDerivedFrom(Type, Type, params Type[])
public static bool IsDerivedFrom(Type type, Type baseType, params Type[] genericTypeParameters)
Parameters
Returns
IsDerivedFrom<TBase>(Type, params Type[])
public static bool IsDerivedFrom<TBase>(Type type, params Type[] genericTypeParameters)
Parameters
Returns
Type Parameters
TBase
IsTypeNameWithAssembly(string)
public static bool IsTypeNameWithAssembly(string typeName)
Parameters
typeNamestring
Returns
SetPropertyValue(object, string, object?)
public static void SetPropertyValue(object instance, string propertyName, object? propertyValue)
Parameters
TryGetProperty(Type, string, out PropertyInfo?)
public static bool TryGetProperty(Type type, string propertyName, out PropertyInfo? property)
Parameters
typeTypepropertyNamestringpropertyPropertyInfo
Returns
TryGetPropertyValue(object?, string?, out object?)
public static bool TryGetPropertyValue(object? instance, string? propertyName, out object? value)
Parameters
Returns
TryInvokeMethod(object, string, object?[]?, out object?)
public static bool TryInvokeMethod(object instance, string methodName, object?[]? arguments, out object? value)
Parameters
Returns
TryInvokeStaticMethod(Type, string, object?[]?, out object?)
public static bool TryInvokeStaticMethod(Type type, string methodName, object?[]? arguments, out object? value)
Parameters
Returns
TrySetPropertyValue(object, string, object?)
public static bool TrySetPropertyValue(object instance, string propertyName, object? value)