C# Client Library
A C# Client Library for the AnalyzeRe REST API
AnalyzeRe.Utilities.ReflectionUtilities Class Reference

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. More...
 
static T GetCustomAttributeFast< T > (this MemberInfo member)
 Gets the specified attribute from the member. More...
 
static MemberInfo GetMemberInfo< T > (Expression< T > expression)
 Get the MemberInfo associated with an Expression, if possible. More...
 
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. More...
 
static FieldInfo[] GetPublicFields_Fast (this Type type)
 Get the public fields of a type. More...
 
static PropertyInfo[] GetPublicProperties_Fast (this Type type)
 Get the public readable instance properties of a type. More...
 
static PropertyInfo[] GetUserFacingProperties (this Type type, bool excludeServerGenerated=false, bool excludeNotWriteable=false)
 Gets the user-facing PropertyInfo that has been filtered from the public properties of the specified type. Excludes properties with the 'IgnoreDataMember' attribute defined from the list, and optionally additional properties. More...
 
static bool IsAttributeDefinedFast (this MemberInfo member, Type attributeType)
 Determines whether the member has the specified attribute defined. More...
 
static bool IsAttributeDefinedFast< T > (this MemberInfo member)
 Determines whether the member has the specified attribute defined. More...
 
static bool IsSubclassOfRawGeneric (Type generic, Type toCheck)
 Checks if a type is a subclass of a generic type. More...
 
static bool PropertyHasAttribute< T > (Expression< T > expression, Type attributeType)
 Determines whether the property denoted by the expression has the specified attribute defined. More...
 
static T ShallowCopy< T > (T toCopy)
 Attempt to make a shallow copy of the specified object by reflecting on its public properties. More...
 

Public Attributes

const BindingFlags PublicInstanceBindingFlags
 Flags for retrieving all declared and inherited public instance members. More...
 

Detailed Description

Utilities that reflect on a type or property expression.

Definition at line 15 of file ReflectionUtilities.cs.

Member Function Documentation

static object AnalyzeRe.Utilities.ReflectionUtilities.GetCustomAttributeFast ( this MemberInfo  member,
Type  attributeType 
)
inlinestatic

Gets the specified attribute from the member.

Parameters
memberThe member to get the custom attribute of.
attributeTypeThe type of the attribute to look for.
Returns
True if the attribute is defined on the specified member.

Definition at line 122 of file ReflectionUtilities.cs.

static T AnalyzeRe.Utilities.ReflectionUtilities.GetCustomAttributeFast< T > ( this MemberInfo  member)
inlinestatic

Gets the specified attribute from the member.

Template Parameters
TThe type of the attribute to look for.
Parameters
memberThe member to get the custom attribute of.
Returns
True if the attribute is defined on the specified member.

Definition at line 113 of file ReflectionUtilities.cs.

static MemberInfo AnalyzeRe.Utilities.ReflectionUtilities.GetMemberInfo< T > ( Expression< T >  expression)
inlinestatic

Get the MemberInfo associated with an Expression, if possible.

Parameters
expressionThe expression to get the MemberInfo from.
Template Parameters
TThe expression body type.
Returns
The MemberInfo, or throws an exception if none was found.
Exceptions
ArgumentExceptionNo MemberExpression found in expression.

Definition at line 48 of file ReflectionUtilities.cs.

static string AnalyzeRe.Utilities.ReflectionUtilities.GetPropertyName< TObject > ( Expression< Func< TObject, object >>  PropertyExpression)
inlinestatic

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.

Template Parameters
TObjectThe object type that contains the specified property.
Parameters
PropertyExpressionA LINQ expression containing the property whose name is to be returned. e.g.: GetPropertyName( ()=>SomeProperty )
Returns
The name of the property in the LINQ expression.

Definition at line 27 of file ReflectionUtilities.cs.

static FieldInfo [] AnalyzeRe.Utilities.ReflectionUtilities.GetPublicFields_Fast ( this Type  type)
inlinestatic

Get the public fields of a type.

Parameters
typeType to get public fields of.
Returns
Array of public fields
Exceptions
ArgumentNullExceptiontype is null.

Definition at line 229 of file ReflectionUtilities.cs.

static PropertyInfo [] AnalyzeRe.Utilities.ReflectionUtilities.GetPublicProperties_Fast ( this Type  type)
inlinestatic

Get the public readable instance properties of a type.

Parameters
typeType to get public properties of.
Returns
Array of public properties
Exceptions
ArgumentNullExceptiontype is null.

Definition at line 181 of file ReflectionUtilities.cs.

static PropertyInfo [] AnalyzeRe.Utilities.ReflectionUtilities.GetUserFacingProperties ( this Type  type,
bool  excludeServerGenerated = false,
bool  excludeNotWriteable = false 
)
inlinestatic

Gets the user-facing PropertyInfo that has been filtered from the public properties of the specified type. Excludes properties with the 'IgnoreDataMember' attribute defined from the list, and optionally additional properties.

Parameters
typeType to get public properties of.
excludeServerGeneratedOptional (Default: False) Exclude properties with the 'ServerGenerated' attribute defined from the list.
excludeNotWriteableOptional (Default: False) Exclude properties that can be read but not written to from the list.
Returns
Array of public properties filtered b the specified parameters.
Exceptions
ArgumentNullExceptiontype is null.

Definition at line 154 of file ReflectionUtilities.cs.

static bool AnalyzeRe.Utilities.ReflectionUtilities.IsAttributeDefinedFast ( this MemberInfo  member,
Type  attributeType 
)
inlinestatic

Determines whether the member has the specified attribute defined.

Parameters
memberThe member to check if an attribute is defined on.
attributeTypeThe type of the attribute to look for.
Returns
True if the attribute is defined.

Definition at line 104 of file ReflectionUtilities.cs.

static bool AnalyzeRe.Utilities.ReflectionUtilities.IsAttributeDefinedFast< T > ( this MemberInfo  member)
inlinestatic

Determines whether the member has the specified attribute defined.

Template Parameters
TThe type of the attribute to look for.
Parameters
memberThe member to check if an attribute is defined on.
Returns
True if the attribute is defined.

Definition at line 95 of file ReflectionUtilities.cs.

static bool AnalyzeRe.Utilities.ReflectionUtilities.IsSubclassOfRawGeneric ( Type  generic,
Type  toCheck 
)
inlinestatic

Checks if a type is a subclass of a generic type.

Definition at line 59 of file ReflectionUtilities.cs.

static bool AnalyzeRe.Utilities.ReflectionUtilities.PropertyHasAttribute< T > ( Expression< T >  expression,
Type  attributeType 
)
inlinestatic

Determines whether the property denoted by the expression has the specified attribute defined.

Template Parameters
TThe expression body type.
Parameters
expressionThe expression to get the MemberInfo from.
attributeTypeThe type of the attribute to look for
Returns
True if the attribute is defined.

Definition at line 79 of file ReflectionUtilities.cs.

static T AnalyzeRe.Utilities.ReflectionUtilities.ShallowCopy< T > ( toCopy)
inlinestatic

Attempt to make a shallow copy of the specified object by reflecting on its public properties.

Parameters
toCopythe object to copy.

Definition at line 241 of file ReflectionUtilities.cs.

Member Data Documentation

const BindingFlags AnalyzeRe.Utilities.ReflectionUtilities.PublicInstanceBindingFlags
Initial value:
=
BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance

Flags for retrieving all declared and inherited public instance members.

Definition at line 18 of file ReflectionUtilities.cs.


The documentation for this class was generated from the following file: