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


C# Arguments.MarkReorderedArgument方法代码示例

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


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

示例1: IsApplicable

        ///
        /// Determines if the candidate method is applicable (section 14.4.2.1)
        /// to the given set of arguments
        /// A return value rates candidate method compatibility,
        /// 0 = the best, int.MaxValue = the worst
        ///
        public int IsApplicable(ResolveContext ec,
            ref Arguments arguments, int arg_count, ref MethodSpec method, ref bool params_expanded_form)
        {
            var candidate = method;

            AParametersCollection pd = candidate.Parameters;
            int param_count = GetApplicableParametersCount (candidate, pd);
            int optional_count = 0;

            if (arg_count != param_count) {
                for (int i = 0; i < pd.Count; ++i) {
                    if (pd.FixedParameters [i].HasDefaultValue) {
                        optional_count = pd.Count - i;
                        break;
                    }
                }

                int args_gap = System.Math.Abs (arg_count - param_count);
                if (optional_count != 0) {
                    if (args_gap > optional_count)
                        return int.MaxValue - 10000 + args_gap - optional_count;

                    // Readjust expected number when params used
                    if (pd.HasParams) {
                        optional_count--;
                        if (arg_count < param_count)
                            param_count--;
                    } else if (arg_count > param_count) {
                        return int.MaxValue - 10000 + args_gap;
                    }
                } else if (arg_count != param_count) {
                    if (!pd.HasParams)
                        return int.MaxValue - 10000 + args_gap;
                    if (arg_count < param_count - 1)
                        return int.MaxValue - 10000 + args_gap;
                }

                // Initialize expanded form of a method with 1 params parameter
                params_expanded_form = param_count == 1 && pd.HasParams;

                // Resize to fit optional arguments
                if (optional_count != 0) {
                    Arguments resized;
                    if (arguments == null) {
                        resized = new Arguments (optional_count);
                    } else {
                        resized = new Arguments (param_count);
                        resized.AddRange (arguments);
                    }

                    for (int i = arg_count; i < param_count; ++i)
                        resized.Add (null);
                    arguments = resized;
                }
            }

            if (arg_count > 0) {
                //
                // Shuffle named arguments to the right positions if there are any
                //
                if (arguments [arg_count - 1] is NamedArgument) {
                    arg_count = arguments.Count;

                    for (int i = 0; i < arg_count; ++i) {
                        bool arg_moved = false;
                        while (true) {
                            NamedArgument na = arguments[i] as NamedArgument;
                            if (na == null)
                                break;

                            int index = pd.GetParameterIndexByName (na.Name);

                            // Named parameter not found or already reordered
                            if (index <= i)
                                break;

                            // When using parameters which should not be available to the user
                            if (index >= param_count)
                                break;

                            if (!arg_moved) {
                                arguments.MarkReorderedArgument (na);
                                arg_moved = true;
                            }

                            Argument temp = arguments[index];
                            arguments[index] = arguments[i];
                            arguments[i] = temp;

                            if (temp == null)
                                break;
                        }
                    }
                } else {
//.........这里部分代码省略.........
开发者ID:speier,项目名称:shake,代码行数:101,代码来源:ecore.cs


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