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


C# CallSignature.GetArgumentKind方法代码示例

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


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

示例1: MakeCheckSelf

        private Expression/*!*/ MakeCheckSelf(DynamicMetaObjectBinder/*!*/ binder, CallSignature signature, DynamicMetaObject/*!*/[]/*!*/ args) {
            ArgumentType firstArgKind = signature.GetArgumentKind(0);

            Expression res;
            if (firstArgKind == ArgumentType.Simple || firstArgKind == ArgumentType.Instance) {
                res = CheckSelf(binder, AstUtils.Convert(Expression, typeof(Method)), args[0].Expression);
            } else if (firstArgKind != ArgumentType.List) {
                res = CheckSelf(binder, AstUtils.Convert(Expression, typeof(Method)), AstUtils.Constant(null));
            } else {
                // list, check arg[0] and then return original list.  If not a list,
                // or we have no items, then check against null & throw.
                res = CheckSelf(
                    binder,
                    AstUtils.Convert(Expression, typeof(Method)),
                    Ast.Condition(
                        Ast.AndAlso(
                            Ast.TypeIs(args[0].Expression, typeof(IList<object>)),
                            Ast.NotEqual(
                                Ast.Property(
                                    Ast.Convert(args[0].Expression, typeof(ICollection)),
                                    typeof(ICollection).GetProperty("Count")
                                ),
                                AstUtils.Constant(0)
                            )
                        ),
                        Ast.Call(
                            Ast.Convert(args[0].Expression, typeof(IList<object>)),
                            typeof(IList<object>).GetMethod("get_Item"),
                            AstUtils.Constant(0)
                        ),
                        AstUtils.Constant(null)
                    )
                );
            }

            return res;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:37,代码来源:MetaMethod.cs

示例2: GetArgumentTypes

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")] // TODO: fix
        private static DynamicMetaObject[] GetArgumentTypes(CallSignature signature, IList<DynamicMetaObject> args) {
            List<DynamicMetaObject> res = new List<DynamicMetaObject>();
            List<DynamicMetaObject> namedObjects = null;
            for (int i = 0; i < args.Count; i++) {
                switch (signature.GetArgumentKind(i)) {
                    case ArgumentType.Named:
                        if (namedObjects == null) {
                            namedObjects = new List<DynamicMetaObject>();
                        }
                        namedObjects.Add(args[i]);
                        break;
                    case ArgumentType.Simple:
                    case ArgumentType.Instance:
                        res.Add(args[i]);
                        break;
                    case ArgumentType.List:
                        IList<object> list = args[i].Value as IList<object>;
                        if (list == null) return null;

                        for (int j = 0; j < list.Count; j++) {
                            res.Add(
                                new DynamicMetaObject(
                                        Ast.Call(
                                            Ast.Convert(
                                                args[i].Expression,
                                                typeof(IList<object>)
                                            ),
                                            typeof(IList<object>).GetMethod("get_Item"),
                                            Ast.Constant(j)
                                        ),
                                        args[i].Restrictions,
                                        list[j]
                                    )
                            );
                        }
                        break;
                    case ArgumentType.Dictionary:
                        // caller needs to process these...
                        break;
                    default:
                        throw new NotImplementedException();
                }
            }

            if (namedObjects != null) {
                res.AddRange(namedObjects);
            }

            return res.ToArray();
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:51,代码来源:DefaultBinder.MethodCalls.cs


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