Class ReflectionExtensions
- Namespace
- LinqToDB.Internal.Extensions
- Assembly
- linq2db.dll
public static class ReflectionExtensions
- Inheritance
-
objectReflectionExtensions
Methods
CanConvertTo(Type, Type)
public static bool CanConvertTo(this Type fromType, Type toType)
Parameters
Returns
EqualsTo(MemberInfo?, MemberInfo?, Type?)
public static bool EqualsTo(this MemberInfo? member1, MemberInfo? member2, Type? declaringType = null)
Parameters
member1MemberInfomember2MemberInfodeclaringTypeType
Returns
GetDefaultConstructorEx(Type)
public static ConstructorInfo? GetDefaultConstructorEx(this Type type)
Parameters
typeType
Returns
GetDefaultValue(Type)
public static object? GetDefaultValue(this Type type)
Parameters
typeType
Returns
- object
GetDefiningTypes(Type, MemberInfo)
public static IEnumerable<Type> GetDefiningTypes(this Type child, MemberInfo member)
Parameters
childTypememberMemberInfo
Returns
GetEventEx(Type, string)
public static EventInfo? GetEventEx(this Type type, string eventName)
Parameters
Returns
GetGenericArguments(Type, Type)
Returns an array of Type objects that represent the type arguments of a generic type or the type parameters of a generic type definition.
public static Type[]? GetGenericArguments(this Type type, Type baseType)
Parameters
Returns
- Type[]
An array of Type objects that represent the type arguments of a generic type. Returns an empty array if the current type is not a generic type.
GetGenericType(Type, Type)
public static Type? GetGenericType(this Type genericType, Type type)
Parameters
Returns
GetGenericTypes(Type, Type)
public static IEnumerable<Type> GetGenericTypes(this Type genericType, Type type)
Parameters
Returns
GetImplementation(Type, MemberInfo)
public static MemberInfo? GetImplementation(this Type concreteType, MemberInfo interfaceMember)
Parameters
concreteTypeTypeinterfaceMemberMemberInfo
Returns
GetInstanceMemberEx(Type, string)
public static MemberInfo[] GetInstanceMemberEx(this Type type, string name)
Parameters
Returns
GetInterfaceMapEx(Type, Type)
public static InterfaceMapping GetInterfaceMapEx(this Type type, Type interfaceType)
Parameters
Returns
GetItemType(Type?)
public static Type? GetItemType(this Type? type)
Parameters
typeType
Returns
GetListItemType(Type)
Gets the Type of list item.
public static Type GetListItemType(this Type listType)
Parameters
Returns
- Type
The Type instance that represents the exact runtime type of list item.
GetMemberEx(Type, MemberInfo)
Returns MemberInfo of type described by memberInfo
It us useful when member's declared and reflected types are not the same.
public static MemberInfo? GetMemberEx(this Type type, MemberInfo memberInfo)
Parameters
typeTypeType to find member info
memberInfoMemberInfo
Returns
- MemberInfo
MemberInfo or null
Remarks
This method searches only properties, fields and methods
GetMemberType(MemberInfo)
public static Type GetMemberType(this MemberInfo memberInfo)
Parameters
memberInfoMemberInfo
Returns
GetMethodEx(Type, string)
public static MethodInfo? GetMethodEx(this Type type, string name)
Parameters
Returns
GetMethodEx(Type, string, int, params Type[])
Gets generic method.
public static MethodInfo? GetMethodEx(this Type type, string name, int genericParametersCount, params Type[] types)
Parameters
Returns
GetMethodEx(Type, string, params Type[])
public static MethodInfo? GetMethodEx(this Type type, string name, params Type[] types)
Parameters
Returns
GetMethodEx(Type, Type, string, params Type[])
Gets method by name, input parameters and return type. Usefull for method overloads by return type, like op_Explicit/op_Implicit conversions.
public static MethodInfo? GetMethodEx(this Type type, Type returnType, string name, params Type[] types)
Parameters
Returns
GetNonPublicPropertiesEx(Type)
public static PropertyInfo[] GetNonPublicPropertiesEx(this Type type)
Parameters
typeType
Returns
GetPropertiesEx(Type)
public static PropertyInfo[] GetPropertiesEx(this Type type)
Parameters
typeType
Returns
GetPropertyInfo(MethodInfo?)
public static PropertyInfo? GetPropertyInfo(this MethodInfo? method)
Parameters
methodMethodInfo
Returns
GetPublicInstanceMethodEx(Type, string, params Type[])
public static MethodInfo? GetPublicInstanceMethodEx(this Type type, string name, params Type[] types)
Parameters
Returns
GetPublicInstanceValueMembers(Type)
public static MemberInfo[] GetPublicInstanceValueMembers(this Type type)
Parameters
typeType
Returns
GetPublicMemberEx(Type, string)
public static MemberInfo[] GetPublicMemberEx(this Type type, string name)
Parameters
Returns
GetStaticMembersEx(Type, string)
public static MemberInfo[] GetStaticMembersEx(this Type type, string name)
Parameters
Returns
IsAnonymous(Type)
public static bool IsAnonymous(this Type type)
Parameters
typeType
Returns
IsEnumerableType(Type, Type)
public static bool IsEnumerableType(this Type type, Type elementType)
Parameters
Returns
IsGenericEnumerableType(Type)
public static bool IsGenericEnumerableType(this Type type)
Parameters
typeType
Returns
IsNullableGetValueOrDefault(MemberInfo)
public static bool IsNullableGetValueOrDefault(this MemberInfo member)
Parameters
memberMemberInfo
Returns
IsNullableHasValueMember(MemberInfo)
public static bool IsNullableHasValueMember(this MemberInfo member)
Parameters
memberMemberInfo
Returns
IsNullableValueMember(MemberInfo)
public static bool IsNullableValueMember(this MemberInfo member)
Parameters
memberMemberInfo
Returns
IsSameOrParentOf(Type, Type)
Determines whether the specified types are considered equal.
public static bool IsSameOrParentOf(this Type parent, Type child)
Parameters
Returns
- bool
True, when an object instance of the type
childcan be used as an object of the typeparent; otherwise, false.
Remarks
Note that nullable types does not have a parent-child relation to it's underlying type. For example, the 'int?' type (nullable int) and the 'int' type aren't a parent and it's child.
IsSubClassOf(Type, Type)
Determines whether the type derives from the specified check.
public static bool IsSubClassOf(this Type type, Type check)
Parameters
Returns
- bool
true if the
typederives fromcheck; otherwise, false.
Remarks
This method also returns false if type and the check are equal.
ToUnderlying(Type)
Returns the underlying type argument of the specified type.
public static Type ToUnderlying(this Type type)