11 [global::__DynamicallyInvokable]
47 if (IsOverridden(
"TryGetMember"))
56 if (IsOverridden(
"TrySetMember"))
65 if (IsOverridden(
"TryDeleteMember"))
74 if (IsOverridden(
"TryConvert"))
84 DynamicMetaObject errorSuggestion = BuildCallMethodWithResult(
"TryInvokeMember", binder,
DynamicMetaObject.GetExpressions(args), BuildCallMethodWithResult(
"TryGetMember",
new GetBinderAdapter(binder), NoArgs, fallback(
null), (
DynamicMetaObject e) => binder.
FallbackInvoke(e, args,
null)),
null);
85 return fallback(errorSuggestion);
90 if (IsOverridden(
"TryCreateInstance"))
99 if (IsOverridden(
"TryInvoke"))
108 if (IsOverridden(
"TryBinaryOperation"))
120 if (IsOverridden(
"TryUnaryOperation"))
129 if (IsOverridden(
"TryGetIndex"))
138 if (IsOverridden(
"TrySetIndex"))
147 if (IsOverridden(
"TryDeleteIndex"))
157 for (
int i = 0; i < args.Length; i++)
159 readOnlyCollectionBuilder.
Add(
Expression.Convert(args[i], typeof(
object)));
161 return readOnlyCollectionBuilder.
ToArray();
167 for (
int i = 0; i < args.Length; i++)
172 if (readOnlyCollectionBuilder ==
null)
179 if (readOnlyCollectionBuilder !=
null)
181 return Expression.Block(readOnlyCollectionBuilder);
188 if (parameters != NoArgs)
221 Type type = binder.GetType();
231 return CallMethodWithResult(methodName, binder, args, fallback,
null);
237 DynamicMetaObject errorSuggestion = BuildCallMethodWithResult(methodName, binder, args, fallbackResult, fallbackInvoke);
238 return fallback(errorSuggestion);
243 if (!IsOverridden(methodName))
245 return fallbackResult;
249 Expression[] convertedArgs = GetConvertedArgs(args);
254 string value = Strings.DynamicObjectResultNotAssignable(
"{0}", Value.GetType(), binder.GetType(), binder.
ReturnType);
259 }),
Expression.Call(typeof(
string).GetMethod(
"Format",
new Type[2]
263 }),
Expression.Constant(value),
Expression.NewArrayInit(typeof(
object),
Expression.Condition(
Expression.Equal(dynamicMetaObject.
Expression,
Expression.Constant(
null)),
Expression.Constant(
"null"),
Expression.Call(dynamicMetaObject.
Expression, typeof(
object).GetMethod(
"GetType")), typeof(
object))))), binder.
ReturnType), binder.
ReturnType);
266 if (fallbackInvoke !=
null)
268 dynamicMetaObject = fallbackInvoke(dynamicMetaObject);
274 }, (methodName !=
"TryBinaryOperation") ?
Expression.Assign(parameterExpression2,
Expression.NewArrayInit(typeof(
object), convertedArgs)) :
Expression.Assign(parameterExpression2, convertedArgs[0]),
Expression.Condition(
Expression.Call(GetLimitedSelf(), typeof(
DynamicObject).GetMethod(methodName), BuildCallArgs(binder, args, parameterExpression2, parameterExpression)),
Expression.Block((methodName !=
"TryBinaryOperation") ? ReferenceArgAssign(parameterExpression2, args) :
Expression.Empty(), dynamicMetaObject.
Expression), fallbackResult.
Expression, binder.
ReturnType)), GetRestrictions().Merge(dynamicMetaObject.
Restrictions).Merge(fallbackResult.
Restrictions));
282 Expression[] convertedArgs = GetConvertedArgs(args);
287 },
Expression.Assign(parameterExpression2,
Expression.NewArrayInit(typeof(
object), convertedArgs)),
Expression.Condition(
Expression.Call(GetLimitedSelf(), typeof(
DynamicObject).GetMethod(methodName), BuildCallArgs(binder, args, parameterExpression2,
Expression.Assign(parameterExpression,
Expression.Convert(value, typeof(
object))))),
Expression.Block(ReferenceArgAssign(parameterExpression2, args), parameterExpression), dynamicMetaObject.
Expression, typeof(
object))), GetRestrictions().Merge(dynamicMetaObject.
Restrictions));
288 return fallback(errorSuggestion);
295 Expression[] convertedArgs = GetConvertedArgs(args);
299 },
Expression.Assign(parameterExpression,
Expression.NewArrayInit(typeof(
object), convertedArgs)),
Expression.Condition(
Expression.Call(GetLimitedSelf(), typeof(
DynamicObject).GetMethod(methodName), BuildCallArgs(binder, args, parameterExpression,
null)),
Expression.Block(ReferenceArgAssign(parameterExpression, args),
Expression.Empty()), dynamicMetaObject.
Expression, typeof(
void))), GetRestrictions().Merge(dynamicMetaObject.
Restrictions));
300 return fallback(errorSuggestion);
303 private bool IsOverridden(
string method)
307 for (
int i = 0; i < array.Length; i++)
325 if (TypeUtils.AreEquivalent(base.Expression.Type, typeof(
DynamicObject)))
327 return base.Expression;
334 [global::__DynamicallyInvokable]
344 [global::__DynamicallyInvokable]
356 [global::__DynamicallyInvokable]
366 [global::__DynamicallyInvokable]
378 [global::__DynamicallyInvokable]
390 [global::__DynamicallyInvokable]
403 [global::__DynamicallyInvokable]
416 [global::__DynamicallyInvokable]
429 [global::__DynamicallyInvokable]
441 [global::__DynamicallyInvokable]
454 [global::__DynamicallyInvokable]
467 [global::__DynamicallyInvokable]
478 [global::__DynamicallyInvokable]
486 [global::__DynamicallyInvokable]
489 return new string[0];
495 [global::__DynamicallyInvokable]
498 return new MetaDynamic(parameter,
this);
Obtains information about the attributes of a member and provides access to member metadata.
Represents an expression that has a constant value.
Represents the dynamic create operation at the call site, providing the binding semantic and the deta...
abstract Type BaseType
Gets the type from which the current T:System.Type directly inherits.
abstract DynamicMetaObject FallbackInvoke(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
When overridden in the derived class, performs the binding of the dynamic invoke operation if the tar...
Represents the dynamic set index operation at the call site, providing the binding semantic and the d...
bool IsVisible
Gets a value indicating whether the T:System.Type can be accessed by code outside the assembly.
DynamicMetaObject FallbackSetMember(DynamicMetaObject target, DynamicMetaObject value)
Performs the binding of the dynamic set member operation if the target dynamic object cannot bind.
abstract MethodInfo GetBaseDefinition()
When overridden in a derived class, returns the T:System.Reflection.MethodInfo object for the method ...
Represents the convert dynamic operation at the call site, providing the binding semantic and the det...
The builder for read only collection.
Discovers the attributes of a method and provides access to method metadata.
virtual bool TryDeleteIndex(DeleteIndexBinder binder, object[] indexes)
Provides the implementation for operations that delete an object by index. This method is not intende...
Represents the dynamic get member operation at the call site, providing the binding semantic and the ...
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
Represents the dynamic set member operation at the call site, providing the binding semantic and the ...
DynamicMetaObject FallbackInvoke(DynamicMetaObject target, DynamicMetaObject[] args)
Performs the binding of the dynamic invoke operation if the target dynamic object cannot bind.
The exception that is thrown for invalid casting or explicit conversion.
DynamicMetaObject FallbackBinaryOperation(DynamicMetaObject target, DynamicMetaObject arg)
Performs the binding of the binary dynamic operation if the target dynamic object cannot bind.
static BindingRestrictions GetTypeRestriction(Expression expression, Type type)
Creates the binding restriction that check the expression for runtime type identity.
Represents a value type that can be assigned null.
Provides a base class for specifying dynamic behavior at run time. This class must be inherited from;...
DynamicMetaObject FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args)
Performs the binding of the dynamic invoke member operation if the target dynamic object cannot bind.
Represents the invoke dynamic operation at the call site, providing the binding semantic and the deta...
static readonly BindingRestrictions Empty
Represents an empty set of binding restrictions. This field is read only.
virtual bool TryInvoke(InvokeBinder binder, object[] args, out object result)
Provides the implementation for operations that invoke an object. Classes derived from the T:System....
DynamicMetaObject FallbackUnaryOperation(DynamicMetaObject target)
Performs the binding of the unary dynamic operation if the target dynamic object cannot bind.
virtual bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
Provides the implementation for operations that invoke a member. Classes derived from the T:System....
DynamicMetaObject FallbackSetIndex(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject value)
Performs the binding of the dynamic set index operation if the target dynamic object cannot bind.
static Type GetUnderlyingType(Type nullableType)
Returns the underlying type argument of the specified nullable type.
virtual bool TryDeleteMember(DeleteMemberBinder binder)
Provides the implementation for operations that delete an object member. This method is not intended ...
DynamicMetaObject FallbackGetMember(DynamicMetaObject target)
Performs the binding of the dynamic get member operation if the target dynamic object cannot bind.
DynamicMetaObject FallbackDeleteMember(DynamicMetaObject target)
Performs the binding of the dynamic delete member operation if the target dynamic object cannot bind.
DynamicMetaObject FallbackConvert(DynamicMetaObject target)
Performs the binding of the dynamic convert operation if the target dynamic object cannot bind.
Provides the base class from which the classes that represent expression tree nodes are derived....
virtual bool TryUnaryOperation(UnaryOperationBinder binder, out object result)
Provides implementation for unary operations. Classes derived from the T:System.Dynamic....
string Name
Gets the name of the member to invoke.
virtual bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
Provides the implementation for operations that get a value by index. Classes derived from the T:Syst...
virtual bool TryBinaryOperation(BinaryOperationBinder binder, object arg, out object result)
Provides implementation for binary operations. Classes derived from the T:System.Dynamic....
virtual bool TryConvert(ConvertBinder binder, out object result)
Provides implementation for type conversion operations. Classes derived from the T:System....
Represents the invoke member dynamic operation at the call site, providing the binding semantic and t...
Represents type declarations: class types, interface types, array types, value types,...
Type DeclaringType
Provides COM objects with version-independent access to the P:System.Reflection.MemberInfo....
DynamicMetaObject FallbackCreateInstance(DynamicMetaObject target, DynamicMetaObject[] args)
Performs the binding of the dynamic create operation if the target dynamic object cannot bind.
DynamicMetaObject FallbackDeleteIndex(DynamicMetaObject target, DynamicMetaObject[] indexes)
Performs the binding of the dynamic delete index operation if the target dynamic object cannot bind.
Represents a named parameter expression.
bool IsValueType
Gets a value indicating whether the T:System.Type is a value type.
virtual IEnumerable< string > GetDynamicMemberNames()
Returns the enumeration of all dynamic member names.
void Add(T item)
Adds an item to the T:System.Runtime.CompilerServices.ReadOnlyCollectionBuilder`1.
Represents a set of binding restrictions on the T:System.Dynamic.DynamicMetaObject under which the dy...
DynamicMetaObject FallbackGetIndex(DynamicMetaObject target, DynamicMetaObject[] indexes)
Performs the binding of the dynamic get index operation if the target dynamic object cannot bind.
virtual bool TryGetMember(GetMemberBinder binder, out object result)
Provides the implementation for operations that get member values. Classes derived from the T:System....
Represents the dynamic get index operation at the call site, providing the binding semantic and the d...
virtual bool TrySetMember(SetMemberBinder binder, object value)
Provides the implementation for operations that set member values. Classes derived from the T:System....
virtual DynamicMetaObject GetMetaObject(Expression parameter)
Provides a T:System.Dynamic.DynamicMetaObject that dispatches to the dynamic virtual methods....
Represents the dynamic delete index operation at the call site, providing the binding semantic and th...
virtual bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
Provides the implementation for operations that set a value by index. Classes derived from the T:Syst...
T [] ToArray()
Copies the elements of the T:System.Runtime.CompilerServices.ReadOnlyCollectionBuilder`1 to a new arr...
Represents the binary dynamic operation at the call site, providing the binding semantic and the deta...
Represents an expression that has a unary operator.
Specifies that the class can be serialized.
Represents the unary dynamic operation at the call site, providing the binding semantic and the detai...
Represents an expression that has a conditional operator.
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
MemberTypes
Marks each type of member that is defined as a derived class of T:System.Reflection....
bool IgnoreCase
Gets the value indicating if the string comparison should ignore the case of the member name.
DynamicObject()
Enables derived types to initialize a new instance of the T:System.Dynamic.DynamicObject type.
Represents the dynamic delete member operation at the call site, providing the binding semantic and t...
virtual bool TryCreateInstance(CreateInstanceBinder binder, object[] args, out object result)
Provides the implementation for operations that initialize a new instance of a dynamic object....