FallbackInvoke() публичный абстрактный Метод

When overridden in the derived class, performs the binding of the dynamic invoke operation if the target dynamic object cannot bind.
This method is called by the target when the target implements the invoke member operation as a sequence of get member, and invoke, to let the DynamicMetaObject request the binding of the invoke operation only.
public abstract FallbackInvoke ( DynamicMetaObject target, DynamicMetaObject args, DynamicMetaObject errorSuggestion ) : DynamicMetaObject
target DynamicMetaObject The target of the dynamic invoke operation.
args DynamicMetaObject The arguments of the dynamic invoke operation.
errorSuggestion DynamicMetaObject The binding result to use if binding fails, or null.
Результат DynamicMetaObject
Пример #1
0
        public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
            var result = TryBindGetMember(binder.Name);
            if (result != null) {
                return binder.FallbackInvoke(result, args, null);
            }

            return base.BindInvokeMember(binder, args);
        }
Пример #2
0
            public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
                // Generate a tree like:
                //
                // {
                //   object result;
                //   TryInvokeMember(payload, out result)
                //      ? result
                //      : TryGetMember(payload, out result)
                //          ? FallbackInvoke(result)
                //          : fallbackResult
                // }
                //
                // Then it calls FallbackInvokeMember with this tree as the
                // "error", giving the language the option of using this
                // tree or doing .NET binding.
                //
                Fallback fallback = e => binder.FallbackInvokeMember(this, args, e);

                var call = BuildCallMethodWithResult(
                    "TryInvokeMember",
                    binder,
                    DynamicMetaObject.GetExpressions(args),
                    BuildCallMethodWithResult(
                        "TryGetMember",
                        new GetBinderAdapter(binder),
                        NoArgs,
                        fallback(null), 
                        (e) => binder.FallbackInvoke(e, args, null)
                    ),
                    null
                );

                return fallback(call);
            }
Пример #3
0
        /// <summary>
        /// Transforms an invoke member into a Python GetMember/Invoke.  The caller should
        /// verify that the given attribute is not resolved against a normal .NET class
        /// before calling this.  If it is a normal .NET member then a fallback InvokeMember
        /// is preferred.
        /// </summary>
        internal static DynamicMetaObject/*!*/ GenericInvokeMember(InvokeMemberBinder/*!*/ action, ValidationInfo valInfo, DynamicMetaObject target, DynamicMetaObject/*!*/[]/*!*/ args) {
            if (target.NeedsDeferral()) {
                return action.Defer(args);
            }

            return AddDynamicTestAndDefer(action, 
                action.FallbackInvoke(
                    new DynamicMetaObject(
                        Binders.Get(
                            PythonContext.GetCodeContext(action),
                            PythonContext.GetPythonContext(action),
                            typeof(object),
                            action.Name,
                            target.Expression
                        ),
                        BindingRestrictionsHelpers.GetRuntimeTypeRestriction(target)
                    ),
                    args,
                    null
                ),
                args,
                valInfo
            );
        }
Пример #4
0
 public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
 {
     return DynamicTryGetMember(binder.Name,
         binder.FallbackInvokeMember(this, args).Expression,
         (tmp) => binder.FallbackInvoke(new DynamicMetaObject(tmp, BindingRestrictions.Empty), args, null).Expression
     );
 }
Пример #5
0
 public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
     ContractUtils.RequiresNotNull(binder, "binder");
     DynamicMetaObject memberValue = GetDynamicMetaObjectForMember(
         binder.Name, 
         binder.IgnoreCase,
         binder.FallbackInvokeMember(this, args)
     );
     //invoke the member value using the language's binder
     return AddDynamicTestAndDefer(
         binder,
         new DynamicMetaObject[] { this },
         Value.Class,
         null,
         binder.FallbackInvoke(memberValue, args, null)
     );
 }
 public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
 {
     Fallback fallback = e => binder.FallbackInvokeMember(this, args, e);
     DynamicMetaObject errorSuggestion = this.BuildCallMethodWithResult("TryInvokeMember", binder, GetArgArray(args), this.BuildCallMethodWithResult("TryGetMember", new GetBinderAdapter(binder), NoArgs, fallback(null), e => binder.FallbackInvoke(e, args, null)), null);
     return fallback(errorSuggestion);
 }
Пример #7
0
            public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
                if (IsOverridden("TryInvokeMember")) {
                    return CallMethodWithResult("TryInvokeMember", binder, GetArgArray(args), (e) => binder.FallbackInvokeMember(this, args, e));
                } else if (IsOverridden("TryGetMember")) {
                    // Generate a tree like:
                    //
                    // {
                    //   object result;
                    //   TryGetMember(payload, out result) ? FallbackInvoke(result) : fallbackResult
                    // }
                    //
                    // Then it calls FallbackInvokeMember with this tree as the
                    // "error", giving the language the option of using this
                    // tree or doing .NET binding.
                    //
                    return CallMethodWithResult(
                        "TryGetMember", new GetBinderAdapter(binder), NoArgs,
                        (e) => binder.FallbackInvokeMember(this, args, e),
                        (e) => binder.FallbackInvoke(e, args, null)
                    );
                }

                return base.BindInvokeMember(binder, args);
            }
Пример #8
0
            public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
            {
                // Generate a tree like:
                //
                // {
                //   object result;
                //   TryInvokeMember(payload, out result)
                //      ? result
                //      : TryGetMember(payload, out result)
                //          ? FallbackInvoke(result)
                //          : fallbackResult
                // }
                //
                // Then it calls FallbackInvokeMember with this tree as the
                // "error", giving the language the option of using this
                // tree or doing .NET binding.
                //
                DynamicMetaObject call = BuildCallMethodWithResult(
                    DynamicObjectTryInvokeMember,
                    binder,
                    GetExpressions(args),
                    BuildCallMethodWithResult(
                        DynamicObjectTryGetMember,
                        new GetBinderAdapter(binder),
                        _noArgs,
                        binder.FallbackInvokeMember(this, args, null),
                        (MetaDynamic @this, GetMemberBinder ignored, DynamicMetaObject e) => binder.FallbackInvoke(e, args, null)
                        ),
                    null
                    );

                return(binder.FallbackInvokeMember(this, args, call));
            }
Пример #9
0
            public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
            {
                Fallback          fallback        = e => binder.FallbackInvokeMember(this, args, e);
                DynamicMetaObject errorSuggestion = this.BuildCallMethodWithResult("TryInvokeMember", binder, GetArgArray(args), this.BuildCallMethodWithResult("TryGetMember", new GetBinderAdapter(binder), NoArgs, fallback(null), e => binder.FallbackInvoke(e, args, null)), null);

                return(fallback(errorSuggestion));
            }
Пример #10
0
 public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
 {
     var expression = Expr.Dynamic(new LuaGetMemberBinder(binder.Name), typeof(object), Expression);
     return binder.FallbackInvoke(new DynamicMetaObject(expression, Restrictions), args, null);
 }