Class Reflector
Provides access to fast reflection routines.
Inherited Members
Namespace: DotNext.Reflection
Assembly: DotNext.Reflection.dll
Syntax
public static class Reflector
Methods
| Improve this Doc View SourceMemberOf<TMember>(Expression<Action>)
Extracts member metadata from expression tree.
Declaration
[Obsolete("Use overloaded generic method that allows to specify delegate type explicitly")]
public static TMember MemberOf<TMember>(Expression<Action> exprTree)
where TMember : MemberInfo
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Action> | exprTree | Expression tree. |
Returns
| Type | Description |
|---|---|
| TMember | Reflected member; or null, if lambda expression doesn't reference a member. |
Type Parameters
| Name | Description |
|---|---|
| TMember | Type of member to reflect. |
MemberOf<TMember, TDelegate>(Expression<TDelegate>)
Extracts member metadata from expression tree.
Declaration
public static TMember MemberOf<TMember, TDelegate>(Expression<TDelegate> exprTree)
where TMember : MemberInfo where TDelegate : Delegate
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<TDelegate> | exprTree | Expression tree. |
Returns
| Type | Description |
|---|---|
| TMember | Reflected member; or null, if lambda expression doesn't reference a member. |
Type Parameters
| Name | Description |
|---|---|
| TMember | Type of member to reflect. |
| TDelegate | The type of lambda expression. |
Unreflect(ConstructorInfo)
Creates dynamic invoker for the constructor.
Declaration
public static DynamicInvoker Unreflect(this ConstructorInfo ctor)
Parameters
| Type | Name | Description |
|---|---|---|
| ConstructorInfo | ctor | The constructor to unreflect. |
Returns
| Type | Description |
|---|---|
| DynamicInvoker | The delegate that can be used to create an object instance. |
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | The type of parameter is ref-like value type. |
Unreflect(FieldInfo, Boolean, BindingFlags)
Creates dynamic invoker for the field.
Declaration
public static DynamicInvoker Unreflect(this FieldInfo field, bool volatileAccess, BindingFlags flags = BindingFlags.GetField | BindingFlags.SetField)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldInfo | field | The field to unreflect. |
| Boolean | volatileAccess | true to generate volatile access to the field. |
| BindingFlags | flags | Describes the access to the field using invoker. |
Returns
| Type | Description |
|---|---|
| DynamicInvoker | The delegate that can be used to access field value. |
Remarks
This method doesn't cache the result so the caller is responsible for storing delegate to the field or cache.
flags supports the following combination of values: GetField, SetField or
both.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| NotSupportedException | The type of |
Unreflect(FieldInfo, BindingFlags)
Creates dynamic invoker for the field.
Declaration
public static DynamicInvoker Unreflect(this FieldInfo field, BindingFlags flags = BindingFlags.GetField | BindingFlags.SetField)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldInfo | field | The field to unreflect. |
| BindingFlags | flags | Describes the access to the field using invoker. |
Returns
| Type | Description |
|---|---|
| DynamicInvoker | The delegate that can be used to access field value. |
Remarks
This method doesn't cache the result so the caller is responsible for storing delegate to the field or cache.
flags supports the following combination of values: GetField, SetField or
both.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| NotSupportedException | The type of |
Unreflect(MethodInfo)
Creates dynamic invoker for the method.
Declaration
public static DynamicInvoker Unreflect(this MethodInfo method)
Parameters
| Type | Name | Description |
|---|---|---|
| MethodInfo | method | The method to unreflect. |
Returns
| Type | Description |
|---|---|
| DynamicInvoker | The delegate that can be used to invoke the method. |
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | The type of parameter or return type is ref-like value type. |
Unreflect<TDelegate>(ConstructorInfo)
Unreflects constructor to its typed and callable representation.
Declaration
public static Constructor<TDelegate> Unreflect<TDelegate>(this ConstructorInfo ctor)
where TDelegate : MulticastDelegate
Parameters
| Type | Name | Description |
|---|---|---|
| ConstructorInfo | ctor | Constructor to unreflect. |
Returns
| Type | Description |
|---|---|
| Constructor<TDelegate> | Unreflected constructor. |
Type Parameters
| Name | Description |
|---|---|
| TDelegate | A delegate representing signature of constructor. |
Unreflect<TValue>(FieldInfo)
Obtains managed pointer to the static field.
Declaration
public static Field<TValue> Unreflect<TValue>(this FieldInfo field)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldInfo | field | The field to unreflect. |
Returns
| Type | Description |
|---|---|
| Field<TValue> | Unreflected static field. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The field type. |
Unreflect<TDelegate>(MethodInfo)
Unreflects method to its typed and callable representation.
Declaration
public static Method<TDelegate> Unreflect<TDelegate>(this MethodInfo method)
where TDelegate : MulticastDelegate
Parameters
| Type | Name | Description |
|---|---|---|
| MethodInfo | method | A method to unreflect. |
Returns
| Type | Description |
|---|---|
| Method<TDelegate> | Unreflected method. |
Type Parameters
| Name | Description |
|---|---|
| TDelegate | A delegate representing signature of method. |
Unreflect<T, TValue>(FieldInfo)
Obtains managed pointer to the instance field.
Declaration
public static Field<T, TValue> Unreflect<T, TValue>(this FieldInfo field)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldInfo | field | The field to unreflect. |
Returns
| Type | Description |
|---|---|
| Field<T, TValue> | Unreflected instance field. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the object that declares instance field. |
| TValue | The field type. |