Class Get
- Namespace
- Dynamitey.DynamicObjects
- Assembly
- Dynamitey.Community.dll
Dynamic Proxy that exposes any properties of objects, and can massage results based on interface
public class Get : BaseForwarder, IDynamicMetaObjectProvider, IEquivalentType, IForwarder
- Inheritance
-
Get
- Implements
- Inherited Members
Constructors
Get(object)
Initializes a new instance of the Get class.
[RequiresDynamicCode("Constructing any BaseForwarder-derived type instantiates System.Dynamic.DynamicObject, whose default constructor requires the DLR's runtime code generation; not supported when AOT-compiled.")]
public Get(object target)
Parameters
targetobjectThe target.
Methods
Create(object)
Creates the proxy over the specified target.
[RequiresDynamicCode("Constructs a Get, which instantiates System.Dynamic.DynamicObject; requires the DLR's runtime code generation and is not supported when AOT-compiled.")]
public static dynamic Create(object target)
Parameters
targetobjectThe target.
Returns
- dynamic
TryGetIndex(GetIndexBinder, object?[]?, out object)
Tries the index of the get.
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "Calls the annotated base.TryGetIndex/MassageResultBasedOnInterface. This is a DynamicObject.TryGetIndex override: it can't carry [RequiresUnreferencedCode] itself without mismatching the unannotated base member, and the DLR invokes it only after the consumer's own dynamic call site already triggered the framework's warning.")]
[UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Same calls as above; see the IL2026 suppression on this member.")]
public override bool TryGetIndex(GetIndexBinder binder, object?[]? indexes, out object result)
Parameters
binderGetIndexBinderThe binder.
indexesobject[]The indexes.
resultobjectThe result.
Returns
TryGetMember(GetMemberBinder, out object?)
Provides the implementation for operations that get member values. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations such as getting a value for a property.
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "Calls the annotated base.TryGetMember/MassageResultBasedOnInterface. This is a DynamicObject.TryGetMember override: it can't carry [RequiresUnreferencedCode] itself without mismatching the unannotated base member, and the DLR invokes it only after the consumer's own dynamic call site already triggered the framework's warning.")]
[UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Same calls as above; see the IL2026 suppression on this member.")]
public override bool TryGetMember(GetMemberBinder binder, out object? result)
Parameters
binderGetMemberBinderProvides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the DynamicObject class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.
resultobjectThe result of the get operation. For example, if the method is called for a property, you can assign the property value to
result.
Returns
- bool
true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.)
TryInvokeMember(InvokeMemberBinder, object?[]?, out object?)
Provides the implementation for operations that invoke a member. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations such as calling a method.
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "Calls the annotated base.TryInvokeMember/Dynamic.InvokeGet/InvokeMethodDelegate/Dynamic.Invoke/MassageResultBasedOnInterface. This is a DynamicObject.TryInvokeMember override: it can't carry [RequiresUnreferencedCode] itself without mismatching the unannotated base member, and the DLR invokes it only after the consumer's own dynamic call site already triggered the framework's warning.")]
[UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Same calls as above; see the IL2026 suppression on this member.")]
public override bool TryInvokeMember(InvokeMemberBinder binder, object?[]? args, out object? result)
Parameters
binderInvokeMemberBinderProvides information about the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is an instance of the class derived from the DynamicObject class, binder.Name returns "SampleMethod". The binder.IgnoreCase property specifies whether the member name is case-sensitive.
argsobject[]The arguments that are passed to the object member during the invoke operation. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is derived from the DynamicObject class,
args[0] is equal to 100.resultobjectThe result of the member invocation.
Returns
- bool
true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)