Class ReflectionUtils
Reflection utilities
Inherited Members
Namespace: Microsoft.Graph.Communications.Common
Assembly: Microsoft.Graph.Communications.Common.dll
Syntax
public static class ReflectionUtils
Methods
DerivesFrom(Type, Type)
Check if the type derives from the base type
Declaration
public static bool DerivesFrom(this Type type, Type baseType)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | Type to check |
| Type | baseType | Base type |
Returns
| Type | Description |
|---|---|
| Boolean | True if it is or derives from the base type |
DerivesFrom<T>(Type)
Check if the type derives from the T type.
Declaration
public static bool DerivesFrom<T>(this Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | Type to check |
Returns
| Type | Description |
|---|---|
| Boolean | True if it is or derives from the base type |
Type Parameters
| Name | Description |
|---|---|
| T | The type to check. |
GetPropertyUsingReflection(Object, String)
Get named property of an object
Declaration
public static object GetPropertyUsingReflection(this object obj, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | obj | Object to get property from. |
| String | name | Name of the property. |
Returns
| Type | Description |
|---|---|
| Object | Value of the property |
GetValueCached(PropertyInfo, Object)
Gets the value using a cached delegate.
Declaration
public static object GetValueCached(this PropertyInfo propertyInfo, object object)
Parameters
| Type | Name | Description |
|---|---|---|
| PropertyInfo | propertyInfo | The property info to use. |
| Object | object | The object containing the property. |
Returns
| Type | Description |
|---|---|
| Object | The fetched object. |
Implements(Type, Type)
Check if type is subclass of a generic type.
Declaration
public static bool Implements(this Type type, Type checkType)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | Type to check. |
| Type | checkType | Generic type. |
Returns
| Type | Description |
|---|---|
| Boolean | True if it is a subclass. |
Implements<T>(Type)
Check if type is subclass of a generic type.
Declaration
public static bool Implements<T>(this Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | Type to check. |
Returns
| Type | Description |
|---|---|
| Boolean | True if it is a subclass. |
Type Parameters
| Name | Description |
|---|---|
| T | The type to check. |
SetPropertyUsingReflection(Object, String, Object)
Set named property of an object
Declaration
public static bool SetPropertyUsingReflection(this object obj, string name, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | obj | Object to get property from. |
| String | name | Name of the property. |
| Object | value | Value of the property. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
SetValueCached(PropertyInfo, Object, Object)
Set the value using a cached delegate.
Declaration
public static void SetValueCached(this PropertyInfo propertyInfo, object object, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| PropertyInfo | propertyInfo | The property info to use. |
| Object | object | The object containing the property. |
| Object | value | The value to be set. |