本文整理汇总了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 {
//.........这里部分代码省略.........