当前位置: 首页>>代码示例>>C#>>正文


C# DynamicMetaObjectBinder类代码示例

本文整理汇总了C#中DynamicMetaObjectBinder的典型用法代码示例。如果您正苦于以下问题:C# DynamicMetaObjectBinder类的具体用法?C# DynamicMetaObjectBinder怎么用?C# DynamicMetaObjectBinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DynamicMetaObjectBinder类属于命名空间,在下文中一共展示了DynamicMetaObjectBinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MakeStandardDotNetTypeCall

        /// <summary>
        /// Creating a standard .NET type is easy - we just call it's constructor with the provided
        /// arguments.
        /// </summary>
        private DynamicMetaObject/*!*/ MakeStandardDotNetTypeCall(DynamicMetaObjectBinder/*!*/ call, Expression/*!*/ codeContext, DynamicMetaObject/*!*/[]/*!*/ args) {
            CallSignature signature = BindingHelpers.GetCallSignature(call);
            BinderState state = BinderState.GetBinderState(call);
            MethodBase[] ctors = CompilerHelpers.GetConstructors(Value.UnderlyingSystemType, state.Binder.PrivateBinding);

            if (ctors.Length > 0) {
                return state.Binder.CallMethod(
                    new ParameterBinderWithCodeContext(state.Binder, codeContext),
                    ctors,
                    args,
                    signature,
                    Restrictions.Merge(BindingRestrictions.GetInstanceRestriction(Expression, Value))
                );
            } else {
                return new DynamicMetaObject(
                   Ast.Throw(
                       Ast.New(
                           typeof(ArgumentTypeException).GetConstructor(new Type[] { typeof(string) }),
                           Ast.Constant("Cannot create instances of " + Value.Name)
                       )
                   ),
                   Restrictions.Merge(BindingRestrictions.GetInstanceRestriction(Expression, Value))
                );
            }
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:29,代码来源:MetaPythonType.Calls.cs

示例2: ConvertWorker

        public DynamicMetaObject ConvertWorker(DynamicMetaObjectBinder binder, Type toType, ConversionResultKind kind) {
            if (toType.IsSubclassOf(typeof(Delegate))) {
                return MakeDelegateTarget(binder, toType, Restrict(typeof(Method)));
            }

            return FallbackConvert(binder);
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:7,代码来源:MetaMethod.cs

示例3: IsNoThrow

        internal static bool IsNoThrow(DynamicMetaObjectBinder action) {
            PythonGetMemberBinder gmb = action as PythonGetMemberBinder;
            if (gmb != null) {
                return gmb.IsNoThrow;
            }

            return false;
        }
开发者ID:m4dc4p,项目名称:ironruby,代码行数:8,代码来源:BindingHelpers.cs

示例4: Dynamic

                    public Expression Dynamic(DynamicMetaObjectBinder binder, Type retType, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
            {
                if(retType == typeof(object))
                    return new TotemDynamicExpression4(binder, this, arg0, arg1, arg2, arg3);
                else if(retType == typeof(bool))
                    return new TotemDynamicExpression4<bool>(binder, this, arg0, arg1, arg2, arg3);

                return ReduceDynamic(binder, retType, arg0, arg1, arg2, arg3);
            }
开发者ID:Alxandr,项目名称:IronTotem-3.0,代码行数:9,代码来源:DynamicExpressions.cs

示例5: ConvertWorker

        public DynamicMetaObject ConvertWorker(DynamicMetaObjectBinder binder, Type toType, ConversionResultKind kind) {
            PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "BuiltinFunc Convert " + toType);
            PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "BuiltinFunc Convert");

            if (toType.IsSubclassOf(typeof(Delegate))) {
                return MakeDelegateTarget(binder, toType, Restrict(LimitType));
            }

            return FallbackConvert(binder);
        }
开发者ID:rafacv,项目名称:iron_languages,代码行数:10,代码来源:MetaBuiltinFunction.cs

示例6: ConvertWorker

        public DynamicMetaObject ConvertWorker(DynamicMetaObjectBinder binder, Type type, Type retType, ConversionResultKind kind) {
            PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "Conversion " + type.FullName);
            PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "Conversion");
            ValidationInfo typeTest = BindingHelpers.GetValidationInfo(this, Value.PythonType);

            return BindingHelpers.AddDynamicTestAndDefer(
                binder,
                TryPythonConversion(binder, type) ?? FallbackConvert(binder),
                new DynamicMetaObject[] { this },
                typeTest,
                retType
            );
        }
开发者ID:jschementi,项目名称:iron,代码行数:13,代码来源:MetaUserObject.cs

示例7: Dynamic

        /*!*/
        public MSAst.Expression Dynamic(DynamicMetaObjectBinder/*!*/ binder, Type/*!*/ retType, MSAst.Expression/*!*/ arg0)
        {
            if (retType == typeof(object))
            {
                throw new NotImplementedException();
                //return new TotemDynamicExpression1(binder, this, arg0);
            }
            else if (retType == typeof(bool))
            {
                throw new NotImplementedException();
                //return new TotemDynamicExpression1<bool>(binder, this, arg0);
            }

            return ReduceDynamic(binder, retType, arg0);
        }
开发者ID:Alxandr,项目名称:IronTotem,代码行数:16,代码来源:CompilationMode.cs

示例8: InvokeWorker

        private DynamicMetaObject/*!*/ InvokeWorker(DynamicMetaObjectBinder/*!*/ call, Expression/*!*/ codeContext, DynamicMetaObject/*!*/[] args) {
            PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "BuiltinMethodDesc Invoke " + Value.DeclaringType + "." + Value.__name__ + " w/ " + args.Length + " args");
            PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "BuiltinMethodDesc Invoke");

            CallSignature signature = BindingHelpers.GetCallSignature(call);
            BindingRestrictions selfRestrict = BindingRestrictions.GetInstanceRestriction(Expression, Value).Merge(Restrictions);

            selfRestrict = selfRestrict.Merge(
                BindingRestrictions.GetExpressionRestriction(
                    MakeFunctionTest(
                        Ast.Call(
                            typeof(PythonOps).GetMethod("GetBuiltinMethodDescriptorTemplate"),
                            Ast.Convert(Expression, typeof(BuiltinMethodDescriptor))
                        )
                    )
                )
            );

            return Value.Template.MakeBuiltinFunctionCall(
                call,
                codeContext,
                this,
                args,
                false,  // no self
                selfRestrict,
                (newArgs) => {
                    BindingTarget target;
                    PythonContext state = PythonContext.GetPythonContext(call);

                    DynamicMetaObject res = state.Binder.CallMethod(
                        new PythonOverloadResolver(
                            state.Binder,
                            newArgs,
                            signature,
                            codeContext
                        ),
                        Value.Template.Targets,
                        selfRestrict,
                        Value.Template.Name,
                        NarrowingLevel.None,
                        Value.Template.IsBinaryOperator ? PythonNarrowing.BinaryOperator : NarrowingLevel.All,
                        out target
                    );

                    return BindingHelpers.CheckLightThrow(call, res, target);
                });            
        }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:47,代码来源:MetaBuiltinMethodDescriptor.cs

示例9: InvokeWorker

        private DynamicMetaObject/*!*/ InvokeWorker(DynamicMetaObjectBinder/*!*/ call, DynamicMetaObject/*!*/[]/*!*/ args, Expression/*!*/ codeContext) {
            if (this.NeedsDeferral()) {
                return call.Defer(ArrayUtils.Insert(this, args));
            }

            for (int i = 0; i < args.Length; i++) {
                if (args[i].NeedsDeferral()) {
                    return call.Defer(ArrayUtils.Insert(this, args));
                }
            }

            if (IsStandardDotNetType(call)) {
                return MakeStandardDotNetTypeCall(call, codeContext, args);
            }

            return MakePythonTypeCall(call, codeContext, args);
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:17,代码来源:MetaPythonType.Calls.cs

示例10: FunctionBinderHelper

            public FunctionBinderHelper(DynamicMetaObjectBinder call, MetaTotemFunction function, Expression codeContext, DynamicMetaObject[] args)
            {
                PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "TotemFunction Invoke " + function.Value.FunctionCompatibility + " w/ " + args.Length + " args");
                PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "TotemFunction");

                _call = call;
                _func = function;
                _args = args;
                _originalArgs = args;
                _temps = new List<ParameterExpression>();
                _codeContext = codeContext;

                // Remove the passed in instance argument if present
                int instanceIndex = Signature.IndexOf(ArgumentType.Instance);
                if (instanceIndex > -1)
                    _args = ArrayUtils.RemoveAt(_args, instanceIndex);
            }
开发者ID:Alxandr,项目名称:IronTotem-3.0,代码行数:17,代码来源:MetaTotemFunction.cs

示例11: FilterShowCls

        internal static DynamicMetaObject/*!*/ FilterShowCls(Expression/*!*/ codeContext, DynamicMetaObjectBinder/*!*/ action, DynamicMetaObject/*!*/ res, Expression/*!*/ failure) {
            if (action is IPythonSite) {
                return new DynamicMetaObject(
                    Ast.Condition(
                        Ast.Call(
                            typeof(PythonOps).GetMethod("IsClsVisible"),
                            codeContext
                        ),
                        AstUtils.Convert(res.Expression, typeof(object)),
                        AstUtils.Convert(failure, typeof(object))

                    ),
                    res.Restrictions
                );
            }

            return res;
        }
开发者ID:m4dc4p,项目名称:ironruby,代码行数:18,代码来源:BindingHelpers.cs

示例12: InvokeWorker

        private DynamicMetaObject/*!*/ InvokeWorker(DynamicMetaObjectBinder/*!*/ call, DynamicMetaObject/*!*/[]/*!*/ args, Expression/*!*/ codeContext) {
            PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "Type Invoke " + Value.UnderlyingSystemType.FullName + args.Length);
            PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "Type Invoke");
            if (this.NeedsDeferral()) {
                return call.Defer(ArrayUtils.Insert(this, args));
            }

            for (int i = 0; i < args.Length; i++) {
                if (args[i].NeedsDeferral()) {
                    return call.Defer(ArrayUtils.Insert(this, args));
                }
            }

            if (IsStandardDotNetType(call)) {
                return MakeStandardDotNetTypeCall(call, codeContext, args);
            }

            return MakePythonTypeCall(call, codeContext, args);
        }
开发者ID:tnachen,项目名称:ironruby,代码行数:19,代码来源:MetaPythonType.Calls.cs

示例13: FilterShowCls

        internal static DynamicMetaObject/*!*/ FilterShowCls(Expression/*!*/ codeContext, DynamicMetaObjectBinder/*!*/ action, DynamicMetaObject/*!*/ res, Expression/*!*/ failure) {
            if (action is IPythonSite) {
                Type resType = BindingHelpers.GetCompatibleType(res.Expression.Type, failure.Type);

                return new DynamicMetaObject(
                    Ast.Condition(
                        Ast.Call(
                            typeof(PythonOps).GetMethod("IsClsVisible"),
                            codeContext
                        ),
                        AstUtils.Convert(res.Expression, resType),
                        AstUtils.Convert(failure, resType)

                    ),
                    res.Restrictions
                );
            }

            return res;
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:20,代码来源:BindingHelpers.cs

示例14: InvokeWorker

        private DynamicMetaObject/*!*/ InvokeWorker(DynamicMetaObjectBinder/*!*/ call, Expression/*!*/ codeContext, DynamicMetaObject/*!*/[]/*!*/ args) {
            PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "BuiltinFunc Invoke " + Value.DeclaringType.FullName + "." + Value.Name + " with " + args.Length + " args " + Value.IsUnbound);
            PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "BuiltinFunction " + Value.Targets.Count + ", " + Value.Targets[0].GetParameters().Length);
            PerfTrack.NoteEvent(PerfTrack.Categories.BindingSlow, "BuiltinFunction " + BindingHelpers.GetCallSignature(call));

            if (this.NeedsDeferral()) {
                return call.Defer(ArrayUtils.Insert(this, args));
            }

            for (int i = 0; i < args.Length; i++) {
                if (args[i].NeedsDeferral()) {
                    return call.Defer(ArrayUtils.Insert(this, args));
                }
            }

            if (Value.IsUnbound) {
                return MakeSelflessCall(call, codeContext, args);
            } else {
                return MakeSelfCall(call, codeContext, args);
            }
        }
开发者ID:tnachen,项目名称:ironruby,代码行数:21,代码来源:MetaBuiltinFunction.cs

示例15: MakeConvertToBool

        private DynamicMetaObject/*!*/ MakeConvertToBool(DynamicMetaObjectBinder/*!*/ conversion) {
            DynamicMetaObject self = Restrict(typeof(OldInstance));

            ParameterExpression tmp = Ast.Variable(typeof(bool?), "tmp");
            DynamicMetaObject fallback = FallbackConvert(conversion);
            Type resType = BindingHelpers.GetCompatibleType(typeof(bool), fallback.Expression.Type);

            return new DynamicMetaObject(
                Ast.Block(
                    new ParameterExpression[] { tmp },
                    Ast.Condition(
                        Ast.NotEqual(
                            Ast.Assign(
                                tmp,
                                Ast.Call(
                                    typeof(PythonOps).GetMethod("OldInstanceConvertToBoolNonThrowing"),
                                    AstUtils.Constant(PythonContext.GetPythonContext(conversion).SharedContext),
                                    self.Expression
                                )
                            ),
                            AstUtils.Constant(null)
                        ),
                        AstUtils.Convert(tmp, resType),
                        AstUtils.Convert(fallback.Expression, resType)
                    )
                ),
                self.Restrictions
            );
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:29,代码来源:MetaOldInstance.cs


注:本文中的DynamicMetaObjectBinder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。