本文整理匯總了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 {
//.........這裏部分代碼省略.........