private DynamicMetaObject InvokeFallback(DynamicMetaObjectBinder action, Expression codeContext, DynamicMetaObject /*!*/[] args)
        {
            InvokeBinder ib = action as InvokeBinder;

            if (ib != null)
            {
                if (_baseMetaObject != null)
                {
                    return(_baseMetaObject.BindInvoke(ib, args));
                }

                return(ib.FallbackInvoke(this.Restrict(this.GetLimitType()), args));
            }

            PythonInvokeBinder pib = action as PythonInvokeBinder;

            if (pib != null)
            {
                IPythonInvokable ipi = _baseMetaObject as IPythonInvokable;
                if (ipi != null)
                {
                    return(ipi.Invoke(pib, codeContext, this, args));
                }

                if (_baseMetaObject != null)
                {
                    return(pib.InvokeForeignObject(this, args));
                }

                return(pib.Fallback(codeContext, this, args));
            }

            // unreachable, we always have one of these binders
            throw new InvalidOperationException();
        }
示例#2
0
        /// <summary>
        /// Helper to do fallback for Invoke's so we can handle both StandardAction and Python's
        /// InvokeBinder.
        /// </summary>
        internal static DynamicMetaObject /*!*/ InvokeFallback(DynamicMetaObjectBinder /*!*/ action, Expression codeContext, DynamicMetaObject target, DynamicMetaObject /*!*/[] /*!*/ args)
        {
            InvokeBinder act = action as InvokeBinder;

            if (act != null)
            {
                return(act.FallbackInvoke(target, args));
            }

            PythonInvokeBinder invoke = action as PythonInvokeBinder;

            if (invoke != null)
            {
                return(invoke.Fallback(codeContext, target, args));
            }

            // unreachable, we always have one of these binders
            throw new InvalidOperationException();
        }