1 /* ****************************************************************************
3 * Copyright (c) Microsoft Corporation.
5 * This source code is subject to terms and conditions of the Microsoft Public License. A
6 * copy of the license can be found in the License.html file at the root of this distribution. If
7 * you cannot locate the Microsoft Public License, please send an email to
8 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
9 * by the terms of the Microsoft Public License.
11 * You must not remove this notice, or any other, from this software.
14 * ***************************************************************************/
15 using System; using Microsoft;
19 using System.Dynamic.Utils;
21 using Microsoft.Scripting.Utils;
25 namespace System.Dynamic {
27 namespace Microsoft.Scripting {
31 /// Represents the invoke dynamic operation at the call site, providing the binding semantic and the details about the operation.
33 public abstract class InvokeBinder : DynamicMetaObjectBinder {
34 private readonly CallInfo _callInfo;
37 /// Initializes a new instance of the <see cref="InvokeBinder" />.
39 /// <param name="callInfo">The signature of the arguments at the call site.</param>
40 protected InvokeBinder(CallInfo callInfo) {
41 ContractUtils.RequiresNotNull(callInfo, "callInfo");
46 /// The result type of the operation.
48 public override sealed Type ReturnType {
49 get { return typeof(object); }
53 /// Gets the signature of the arguments at the call site.
55 public CallInfo CallInfo {
56 get { return _callInfo; }
60 /// Performs the binding of the dynamic invoke operation if the target dynamic object cannot bind.
62 /// <param name="target">The target of the dynamic invoke operation.</param>
63 /// <param name="args">The arguments of the dynamic invoke operation.</param>
64 /// <returns>The <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
65 public DynamicMetaObject FallbackInvoke(DynamicMetaObject target, DynamicMetaObject[] args) {
66 return FallbackInvoke(target, args, null);
70 /// Performs the binding of the dynamic invoke operation if the target dynamic object cannot bind.
72 /// <param name="target">The target of the dynamic invoke operation.</param>
73 /// <param name="args">The arguments of the dynamic invoke operation.</param>
74 /// <param name="errorSuggestion">The binding result to use if binding fails, or null.</param>
75 /// <returns>The <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
76 public abstract DynamicMetaObject FallbackInvoke(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion);
79 /// Performs the binding of the dynamic invoke operation.
81 /// <param name="target">The target of the dynamic invoke operation.</param>
82 /// <param name="args">An array of arguments of the dynamic invoke operation.</param>
83 /// <returns>The <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
84 public sealed override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args) {
85 ContractUtils.RequiresNotNull(target, "target");
86 ContractUtils.RequiresNotNullItems(args, "args");
88 return target.BindInvoke(this, args);
91 // this is a standard DynamicMetaObjectBinder
92 internal override sealed bool IsStandardBinder {