Class ReflectionUtils
Inheritance
System.Object
ReflectionUtils
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Bayat.Json.Runtime.dll
Syntax
public static class ReflectionUtils
Fields
|
Improve this Doc
View Source
EmptyTypes
Declaration
public static readonly Type[] EmptyTypes
Field Value
Type |
Description |
System.Type[] |
|
Methods
|
Improve this Doc
View Source
CanReadMemberValue(MemberInfo, Boolean)
Determines whether the specified MemberInfo can be read.
Declaration
public static bool CanReadMemberValue(MemberInfo member, bool nonPublic)
Parameters
Type |
Name |
Description |
System.Reflection.MemberInfo |
member |
The MemberInfo to determine whether can be read.
|
System.Boolean |
nonPublic |
if set to true then allow the member to be gotten non-publicly.
|
Returns
Type |
Description |
System.Boolean |
true if the specified MemberInfo can be read; otherwise, false .
|
|
Improve this Doc
View Source
CanSetMemberValue(MemberInfo, Boolean, Boolean)
Determines whether the specified MemberInfo can be set.
Declaration
public static bool CanSetMemberValue(MemberInfo member, bool nonPublic, bool canSetReadOnly)
Parameters
Type |
Name |
Description |
System.Reflection.MemberInfo |
member |
The MemberInfo to determine whether can be set.
|
System.Boolean |
nonPublic |
if set to true then allow the member to be set non-publicly.
|
System.Boolean |
canSetReadOnly |
if set to true then allow the member to be set if read-only.
|
Returns
Type |
Description |
System.Boolean |
true if the specified MemberInfo can be set; otherwise, false .
|
|
Improve this Doc
View Source
EnsureNotNullableType(Type)
Declaration
public static Type EnsureNotNullableType(Type t)
Parameters
Type |
Name |
Description |
System.Type |
t |
|
Returns
Type |
Description |
System.Type |
|
|
Improve this Doc
View Source
GetAttribute<T>(Object)
Declaration
public static T GetAttribute<T>(object attributeProvider)
where T : Attribute
Parameters
Type |
Name |
Description |
System.Object |
attributeProvider |
|
Returns
Type Parameters
|
Improve this Doc
View Source
GetAttribute<T>(Object, Boolean)
Declaration
public static T GetAttribute<T>(object attributeProvider, bool inherit)
where T : Attribute
Parameters
Type |
Name |
Description |
System.Object |
attributeProvider |
|
System.Boolean |
inherit |
|
Returns
Type Parameters
|
Improve this Doc
View Source
GetAttributes(Object, Type, Boolean)
Declaration
public static Attribute[] GetAttributes(object attributeProvider, Type attributeType, bool inherit)
Parameters
Type |
Name |
Description |
System.Object |
attributeProvider |
|
System.Type |
attributeType |
|
System.Boolean |
inherit |
|
Returns
Type |
Description |
System.Attribute[] |
|
|
Improve this Doc
View Source
GetAttributes<T>(Object, Boolean)
Declaration
public static T[] GetAttributes<T>(object attributeProvider, bool inherit)
where T : Attribute
Parameters
Type |
Name |
Description |
System.Object |
attributeProvider |
|
System.Boolean |
inherit |
|
Returns
Type Parameters
|
Improve this Doc
View Source
GetBaseDefinition(PropertyInfo)
Declaration
public static MethodInfo GetBaseDefinition(this PropertyInfo propertyInfo)
Parameters
Type |
Name |
Description |
System.Reflection.PropertyInfo |
propertyInfo |
|
Returns
Type |
Description |
System.Reflection.MethodInfo |
|
|
Improve this Doc
View Source
GetCollectionItemType(Type)
Gets the type of the typed collection's items.
Declaration
public static Type GetCollectionItemType(Type type)
Parameters
Type |
Name |
Description |
System.Type |
type |
The type.
|
Returns
Type |
Description |
System.Type |
The type of the typed collection's items.
|
|
Improve this Doc
View Source
GetDefaultConstructor(Type)
Declaration
public static ConstructorInfo GetDefaultConstructor(Type t)
Parameters
Type |
Name |
Description |
System.Type |
t |
|
Returns
Type |
Description |
System.Reflection.ConstructorInfo |
|
|
Improve this Doc
View Source
GetDefaultConstructor(Type, Boolean)
Declaration
public static ConstructorInfo GetDefaultConstructor(Type t, bool nonPublic)
Parameters
Type |
Name |
Description |
System.Type |
t |
|
System.Boolean |
nonPublic |
|
Returns
Type |
Description |
System.Reflection.ConstructorInfo |
|
|
Improve this Doc
View Source
GetDefaultValue(Type)
Declaration
public static object GetDefaultValue(Type type)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
Returns
Type |
Description |
System.Object |
|
|
Improve this Doc
View Source
GetDictionaryKeyValueTypes(Type, out Type, out Type)
Declaration
public static void GetDictionaryKeyValueTypes(Type dictionaryType, out Type keyType, out Type valueType)
Parameters
Type |
Name |
Description |
System.Type |
dictionaryType |
|
System.Type |
keyType |
|
System.Type |
valueType |
|
|
Improve this Doc
View Source
GetFields(Type, BindingFlags)
Declaration
public static IEnumerable<FieldInfo> GetFields(Type targetType, BindingFlags bindingAttr)
Parameters
Type |
Name |
Description |
System.Type |
targetType |
|
System.Reflection.BindingFlags |
bindingAttr |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.Reflection.FieldInfo> |
|
|
Improve this Doc
View Source
GetFieldsAndProperties(Type, BindingFlags)
Declaration
public static List<MemberInfo> GetFieldsAndProperties(Type type, BindingFlags bindingAttr)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
System.Reflection.BindingFlags |
bindingAttr |
|
Returns
Type |
Description |
System.Collections.Generic.List<System.Reflection.MemberInfo> |
|
|
Improve this Doc
View Source
GetMemberInfoFromType(Type, MemberInfo)
Declaration
public static MemberInfo GetMemberInfoFromType(Type targetType, MemberInfo memberInfo)
Parameters
Type |
Name |
Description |
System.Type |
targetType |
|
System.Reflection.MemberInfo |
memberInfo |
|
Returns
Type |
Description |
System.Reflection.MemberInfo |
|
|
Improve this Doc
View Source
GetMemberUnderlyingType(MemberInfo)
Gets the member's underlying type.
Declaration
public static Type GetMemberUnderlyingType(MemberInfo member)
Parameters
Type |
Name |
Description |
System.Reflection.MemberInfo |
member |
The member.
|
Returns
Type |
Description |
System.Type |
The underlying type of the member.
|
|
Improve this Doc
View Source
GetMemberValue(MemberInfo, Object)
Gets the member's value on the object.
Declaration
public static object GetMemberValue(MemberInfo member, object target)
Parameters
Type |
Name |
Description |
System.Reflection.MemberInfo |
member |
The member.
|
System.Object |
target |
The target object.
|
Returns
Type |
Description |
System.Object |
The member's value on the object.
|
|
Improve this Doc
View Source
GetObjectType(Object)
Declaration
public static Type GetObjectType(object v)
Parameters
Type |
Name |
Description |
System.Object |
v |
|
Returns
Type |
Description |
System.Type |
|
|
Improve this Doc
View Source
GetProperties(Type, BindingFlags)
Declaration
public static IEnumerable<PropertyInfo> GetProperties(Type targetType, BindingFlags bindingAttr)
Parameters
Type |
Name |
Description |
System.Type |
targetType |
|
System.Reflection.BindingFlags |
bindingAttr |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.Reflection.PropertyInfo> |
|
|
Improve this Doc
View Source
Declaration
public static string GetTypeName(Type t, FormatterAssemblyStyle assemblyFormat, SerializationBinder binder)
Parameters
Type |
Name |
Description |
System.Type |
t |
|
System.Runtime.Serialization.Formatters.FormatterAssemblyStyle |
assemblyFormat |
|
System.Runtime.Serialization.SerializationBinder |
binder |
|
Returns
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
HasDefaultConstructor(Type, Boolean)
Declaration
public static bool HasDefaultConstructor(Type t, bool nonPublic)
Parameters
Type |
Name |
Description |
System.Type |
t |
|
System.Boolean |
nonPublic |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
ImplementsGenericDefinition(Type, Type)
Declaration
public static bool ImplementsGenericDefinition(Type type, Type genericInterfaceDefinition)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
System.Type |
genericInterfaceDefinition |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
ImplementsGenericDefinition(Type, Type, out Type)
Declaration
public static bool ImplementsGenericDefinition(Type type, Type genericInterfaceDefinition, out Type implementingType)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
System.Type |
genericInterfaceDefinition |
|
System.Type |
implementingType |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
InheritsGenericDefinition(Type, Type)
Declaration
public static bool InheritsGenericDefinition(Type type, Type genericClassDefinition)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
System.Type |
genericClassDefinition |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
InheritsGenericDefinition(Type, Type, out Type)
Declaration
public static bool InheritsGenericDefinition(Type type, Type genericClassDefinition, out Type implementingType)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
System.Type |
genericClassDefinition |
|
System.Type |
implementingType |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
IsGenericDefinition(Type, Type)
Declaration
public static bool IsGenericDefinition(Type type, Type genericInterfaceDefinition)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
System.Type |
genericInterfaceDefinition |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
IsIndexedProperty(MemberInfo)
Determines whether the member is an indexed property.
Declaration
public static bool IsIndexedProperty(MemberInfo member)
Parameters
Type |
Name |
Description |
System.Reflection.MemberInfo |
member |
The member.
|
Returns
Type |
Description |
System.Boolean |
true if the member is an indexed property; otherwise, false .
|
|
Improve this Doc
View Source
IsIndexedProperty(PropertyInfo)
Determines whether the property is an indexed property.
Declaration
public static bool IsIndexedProperty(PropertyInfo property)
Parameters
Type |
Name |
Description |
System.Reflection.PropertyInfo |
property |
The property.
|
Returns
Type |
Description |
System.Boolean |
true if the property is an indexed property; otherwise, false .
|
|
Improve this Doc
View Source
IsMethodOverridden(Type, Type, String)
Declaration
public static bool IsMethodOverridden(Type currentType, Type methodDeclaringType, string method)
Parameters
Type |
Name |
Description |
System.Type |
currentType |
|
System.Type |
methodDeclaringType |
|
System.String |
method |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
IsNullable(Type)
Declaration
public static bool IsNullable(Type t)
Parameters
Type |
Name |
Description |
System.Type |
t |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
IsNullableType(Type)
Declaration
public static bool IsNullableType(Type t)
Parameters
Type |
Name |
Description |
System.Type |
t |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
IsPublic(PropertyInfo)
Declaration
public static bool IsPublic(PropertyInfo property)
Parameters
Type |
Name |
Description |
System.Reflection.PropertyInfo |
property |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
IsVirtual(PropertyInfo)
Declaration
public static bool IsVirtual(this PropertyInfo propertyInfo)
Parameters
Type |
Name |
Description |
System.Reflection.PropertyInfo |
propertyInfo |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
RemoveFlag(BindingFlags, BindingFlags)
Declaration
public static BindingFlags RemoveFlag(this BindingFlags bindingAttr, BindingFlags flag)
Parameters
Type |
Name |
Description |
System.Reflection.BindingFlags |
bindingAttr |
|
System.Reflection.BindingFlags |
flag |
|
Returns
Type |
Description |
System.Reflection.BindingFlags |
|
|
Improve this Doc
View Source
SetMemberValue(MemberInfo, Object, Object)
Sets the member's value on the target object.
Declaration
public static void SetMemberValue(MemberInfo member, object target, object value)
Parameters
Type |
Name |
Description |
System.Reflection.MemberInfo |
member |
The member.
|
System.Object |
target |
The target.
|
System.Object |
value |
The value.
|
|
Improve this Doc
View Source
SplitFullyQualifiedTypeName(String, out String, out String)
Declaration
public static void SplitFullyQualifiedTypeName(string fullyQualifiedTypeName, out string typeName, out string assemblyName)
Parameters
Type |
Name |
Description |
System.String |
fullyQualifiedTypeName |
|
System.String |
typeName |
|
System.String |
assemblyName |
|