C# Client Library
A C# Client Library for the AnalyzeRe REST API
|
Utilities that reflect on a type or property expression. More...
Static Public Member Functions | |
static object | GetCustomAttributeFast (this MemberInfo member, Type attributeType) |
Gets the specified attribute from the member. | |
static T | GetCustomAttributeFast< T > (this MemberInfo member) |
Gets the specified attribute from the member. | |
static MemberInfo | GetMemberInfo< T > (Expression< T > expression) |
Get the MemberInfo associated with an Expression, if possible. | |
static string | GetPropertyName< TObject > (Expression< Func< TObject, object > > propertyExpression) |
Gets the string name of a property from a LINQ expression such as GetPropertyName( ()=>SomeProperty ). This is a preferred method of generating string property names for property changed notification since it is not susceptible to property renaming or typos. | |
static FieldInfo[] | GetPublicFields_Fast (this Type type) |
Get all public instance fields of a type, and cache the result so that future reflection on the same type is faster. | |
static PropertyInfo[] | GetPublicProperties_Fast (this Type type) |
Get all public instance properties of a type, and cache the result so that future reflection on the same type is faster. | |
static PropertyInfo[] | GetUserFacingProperties (this Type type, bool excludeServerGenerated=false, bool excludeNotWritable=false, bool excludeNotSerialized=false) |
Gets the "user-facing" PropertyInfo, which has been filtered from the set of all public properties of the specified type. Excludes from the list any properties that cannot be read, or that have the attribute ObsoleteAttribute and/or InternalMemberAttribute defined (which means those properties are intended for internal use). Optionally excludes properties based on other attributes depending on arguments. | |
static bool | IsAttributeDefinedFast (this MemberInfo member, Type attributeType) |
Determines whether the member has the specified attribute defined. | |
static bool | IsAttributeDefinedFast< T > (this MemberInfo member) |
Determines whether the member has the specified attribute defined. | |
static bool | IsSubclassOfRawGeneric (this Type toCheck, Type generic) |
Checks if a type is a subclass of a generic type. | |
static bool | PropertyHasAttribute< T > (Expression< T > expression, Type attributeType) |
Determines whether the property denoted by the expression has the specified attribute defined. | |
static T | ShallowCopy< T > (T toCopy) |
Attempt to make a shallow copy of the specified object by reflecting on its public properties. | |
Static Public Attributes | |
const BindingFlags | PublicInstanceBindingFlags |
Flags for retrieving all declared and inherited public instance members. | |
Utilities that reflect on a type or property expression.
Definition at line 14 of file ReflectionUtilities.cs.
|
inlinestatic |
Gets the specified attribute from the member.
member | The member to get the custom attribute of. |
attributeType | The type of the attribute to look for. |
Definition at line 108 of file ReflectionUtilities.cs.
|
inlinestatic |
Gets the specified attribute from the member.
T | The type of the attribute to look for. |
member | The member to get the custom attribute of. |
Definition at line 99 of file ReflectionUtilities.cs.
|
inlinestatic |
Get the MemberInfo associated with an Expression, if possible.
expression | The expression to get the MemberInfo from. |
T | The expression body type. |
ArgumentException | No MemberExpression found in expression. |
Definition at line 35 of file ReflectionUtilities.cs.
|
static |
Gets the string name of a property from a LINQ expression such as GetPropertyName( ()=>SomeProperty ). This is a preferred method of generating string property names for property changed notification since it is not susceptible to property renaming or typos.
TObject | The object type that contains the specified property. |
propertyExpression | A LINQ expression containing the property whose name is to be returned. e.g.: GetPropertyName( ()=>SomeProperty ) |
|
inlinestatic |
Get all public instance fields of a type, and cache the result so that future reflection on the same type is faster.
type | Type to get public fields of. |
ArgumentNullException | type is null. |
Definition at line 253 of file ReflectionUtilities.cs.
|
inlinestatic |
Get all public instance properties of a type, and cache the result so that future reflection on the same type is faster.
type | Type to get public properties of. |
ArgumentNullException | type is null. |
Definition at line 206 of file ReflectionUtilities.cs.
|
inlinestatic |
Gets the "user-facing" PropertyInfo, which has been filtered from the set of all public properties of the specified type. Excludes from the list any properties that cannot be read, or that have the attribute ObsoleteAttribute and/or InternalMemberAttribute defined (which means those properties are intended for internal use). Optionally excludes properties based on other attributes depending on arguments.
type | Type to get public properties of. |
excludeServerGenerated | Optional (Default: False) Exclude properties that carry the ServerGenerated attribute, meaning that this property is normally assigned its value by the server, not the user. |
excludeNotWritable | Optional (Default: False) Exclude properties that cannot be assigned to (do not have a "set" method) from the list. |
excludeNotSerialized | Optional (Default: False) Exclude properties that carry the IgnoreDataMemberAttribute attribute, meaning that they are not serialized to JSON when transmitting the object to/from the API. |
ArgumentNullException | type is null. |
Definition at line 147 of file ReflectionUtilities.cs.
|
inlinestatic |
Determines whether the member has the specified attribute defined.
member | The member to check if an attribute is defined on. |
attributeType | The type of the attribute to look for. |
Definition at line 90 of file ReflectionUtilities.cs.
|
inlinestatic |
Determines whether the member has the specified attribute defined.
T | The type of the attribute to look for. |
member | The member to check if an attribute is defined on. |
Definition at line 81 of file ReflectionUtilities.cs.
|
inlinestatic |
Checks if a type is a subclass of a generic type.
Definition at line 47 of file ReflectionUtilities.cs.
|
inlinestatic |
Determines whether the property denoted by the expression has the specified attribute defined.
T | The expression body type. |
expression | The expression to get the MemberInfo from. |
attributeType | The type of the attribute to look for |
Definition at line 65 of file ReflectionUtilities.cs.
|
inlinestatic |
Attempt to make a shallow copy of the specified object by reflecting on its public properties.
toCopy | the object to copy. |
Definition at line 266 of file ReflectionUtilities.cs.
|
static |
Flags for retrieving all declared and inherited public instance members.
Definition at line 17 of file ReflectionUtilities.cs.