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


C# ActionBinder.MakeCallExpression方法代码示例

本文整理汇总了C#中Microsoft.Scripting.Actions.ActionBinder.MakeCallExpression方法的典型用法代码示例。如果您正苦于以下问题:C# ActionBinder.MakeCallExpression方法的具体用法?C# ActionBinder.MakeCallExpression怎么用?C# ActionBinder.MakeCallExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Scripting.Actions.ActionBinder的用法示例。


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

示例1: GetValue

        public override DynamicMetaObject GetValue(OverloadResolverFactory resolverFactory, ActionBinder binder, Type type) {
            if (!IsStatic || GetIndexParameters().Length > 0) {
                // need to bind to a value or parameters to get the value.
                return binder.ReturnMemberTracker(type, this);
            }

            MethodInfo getter = ResolveGetter(binder.PrivateBinding);
            if (getter == null || getter.ContainsGenericParameters) {
                // no usable getter
                return null;
            }

            if (getter.IsPublic && getter.DeclaringType.IsPublic) {
                return binder.MakeCallExpression(resolverFactory, getter);
            }

            // private binding is just a call to the getter method...
            return MemberTracker.FromMemberInfo(getter).Call(resolverFactory, binder);
        }
开发者ID:jschementi,项目名称:iron,代码行数:19,代码来源:PropertyTracker.cs

示例2: Call

        internal override System.Linq.Expressions.Expression Call(Expression context, ActionBinder binder, params Expression[] arguments) {
            if (Method.IsPublic && Method.DeclaringType.IsVisible) {
                // TODO: Need to use MethodBinder in here to make this right.
                return binder.MakeCallExpression(context, Method, arguments);
            }

            //methodInfo.Invoke(obj, object[] params)
            if (Method.IsStatic) {
                return Ast.Convert(
                    Ast.Call(
                        Ast.Constant(Method),
                        typeof(MethodInfo).GetMethod("Invoke", new Type[] { typeof(object), typeof(object[]) }),
                        Ast.Constant(null),
                        AstUtils.NewArrayHelper(typeof(object), arguments)
                    ),
                    Method.ReturnType);
            }

            if (arguments.Length == 0) throw Error.NoInstanceForCall();

            return Ast.Convert(
                Ast.Call(
                    Ast.Constant(Method),
                    typeof(MethodInfo).GetMethod("Invoke", new Type[] { typeof(object), typeof(object[]) }),
                    arguments[0],
                    AstUtils.NewArrayHelper(typeof(object), ArrayUtils.RemoveFirst(arguments))
                ),
                Method.ReturnType);
        }
开发者ID:bclubb,项目名称:ironruby,代码行数:29,代码来源:MethodTracker.cs

示例3: Call

        internal override DynamicMetaObject Call(OverloadResolverFactory resolverFactory, ActionBinder binder, params DynamicMetaObject[] arguments) {
            if (Method.IsPublic && Method.DeclaringType.IsVisible) {
                return binder.MakeCallExpression(resolverFactory, Method, arguments);
            }

            //methodInfo.Invoke(obj, object[] params)
            if (Method.IsStatic) {
                return new DynamicMetaObject(
                        Ast.Convert(
                            Ast.Call(
                                AstUtils.Constant(Method),
                                typeof(MethodInfo).GetMethod("Invoke", new Type[] { typeof(object), typeof(object[]) }),
                                AstUtils.Constant(null),
                                AstUtils.NewArrayHelper(typeof(object), ArrayUtils.ConvertAll(arguments, x => x.Expression))
                            ),
                            Method.ReturnType
                        ),
                        BindingRestrictions.Empty
                    )
                ;
            }

            if (arguments.Length == 0) throw Error.NoInstanceForCall();

            return new DynamicMetaObject(
                Ast.Convert(
                    Ast.Call(
                        AstUtils.Constant(Method),
                        typeof(MethodInfo).GetMethod("Invoke", new Type[] { typeof(object), typeof(object[]) }),
                        arguments[0].Expression,
                        AstUtils.NewArrayHelper(typeof(object), ArrayUtils.ConvertAll(ArrayUtils.RemoveFirst(arguments), x => x.Expression))
                    ),
                    Method.ReturnType
                ),
                BindingRestrictions.Empty
            );
        }
开发者ID:jschementi,项目名称:iron,代码行数:37,代码来源:MethodTracker.cs

示例4: Call

        public override Microsoft.Scripting.Ast.Expression Call(ActionBinder binder, params Expression[] arguments) {
            if (Method.IsPublic && Method.DeclaringType.IsVisible) {
                // TODO: Need to use MethodBinder in here to make this right.
                return binder.MakeCallExpression(Method, arguments);
            }

            //methodInfo.Invoke(obj, object[] params)
            if (Method.IsStatic) {
                return Ast.Convert(
                    Ast.Call(
                        Ast.RuntimeConstant(Method),
                        typeof(MethodInfo).GetMethod("Invoke", new Type[] { typeof(object), typeof(object[]) }),
                        Ast.Null(),
                        Ast.NewArrayHelper(typeof(object[]), arguments)),
                    Method.ReturnType);
            } 

            if (arguments.Length == 0) throw new InvalidOperationException("no instance for call");

            return Ast.Convert(
                Ast.Call(
                    Ast.RuntimeConstant(Method),
                    typeof(MethodInfo).GetMethod("Invoke", new Type[] { typeof(object), typeof(object[]) }),
                    arguments[0],
                    Ast.NewArrayHelper(typeof(object[]), ArrayUtils.RemoveFirst(arguments))),
                Method.ReturnType);                       
        }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:27,代码来源:MethodTracker.cs

示例5: GetBoundValue

        protected internal override Expression GetBoundValue(Expression context, ActionBinder binder, Type type, Expression instance) {
            if (instance != null && IsStatic) {
                return null;
            }

            if (GetIndexParameters().Length > 0) {
                // need to bind to a value or parameters to get the value.
                return binder.ReturnMemberTracker(type, BindToInstance(instance));
            }

            MethodInfo getter = GetGetMethod(true);
            if (getter == null || getter.ContainsGenericParameters) {
                // no usable getter
                return null;
            }

            getter = CompilerHelpers.TryGetCallableMethod(getter);

            if (binder.PrivateBinding || CompilerHelpers.IsVisible(getter)) {
                return binder.MakeCallExpression(context, getter, instance);
            }

            // private binding is just a call to the getter method...
            return DefaultBinder.MakeError(((DefaultBinder)binder).MakeNonPublicMemberGetError(context, this, type, instance));
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:25,代码来源:PropertyTracker.cs


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