本文整理汇总了C#中Mono.CSharp.MethodGroupExpr.IsApplicable方法的典型用法代码示例。如果您正苦于以下问题:C# MethodGroupExpr.IsApplicable方法的具体用法?C# MethodGroupExpr.IsApplicable怎么用?C# MethodGroupExpr.IsApplicable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.MethodGroupExpr
的用法示例。
在下文中一共展示了MethodGroupExpr.IsApplicable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyApplicability
// <summary>
// Verifies whether the invocation arguments are compatible with the
// delegate's target method
// </summary>
public static bool VerifyApplicability (ResolveContext ec, Type delegate_type, ref Arguments args, Location loc)
{
int arg_count;
if (args == null)
arg_count = 0;
else
arg_count = args.Count;
MethodBase mb = GetInvokeMethod (ec.Compiler, ec.CurrentType, delegate_type);
MethodGroupExpr me = new MethodGroupExpr (new MemberInfo [] { mb }, delegate_type, loc);
AParametersCollection pd = TypeManager.GetParameterData (mb);
int pd_count = pd.Count;
bool params_method = pd.HasParams;
bool is_params_applicable = false;
bool is_applicable = me.IsApplicable (ec, ref args, arg_count, ref mb, ref is_params_applicable) == 0;
if (args != null)
arg_count = args.Count;
if (!is_applicable && !params_method && arg_count != pd_count) {
ec.Report.Error (1593, loc, "Delegate `{0}' does not take `{1}' arguments",
TypeManager.CSharpName (delegate_type), arg_count.ToString ());
return false;
}
return me.VerifyArgumentsCompat (
ec, ref args, arg_count, mb,
is_params_applicable || (!is_applicable && params_method),
false, loc);
}
示例2: DoResolve
protected override Expression DoResolve(ResolveContext ec)
{
if (InstanceExpr is EventExpr) {
((EventExpr) InstanceExpr).Error_CannotAssign (ec);
return null;
}
TypeSpec del_type = InstanceExpr.Type;
if (del_type == null)
return null;
method = Delegate.GetInvokeMethod (ec.Compiler, del_type);
var mb = method;
var me = new MethodGroupExpr (mb, del_type, loc);
me.InstanceExpression = InstanceExpr;
AParametersCollection pd = mb.Parameters;
int pd_count = pd.Count;
int arg_count = arguments == null ? 0 : arguments.Count;
bool params_method = pd.HasParams;
bool is_params_applicable = false;
bool is_applicable = me.IsApplicable (ec, ref arguments, arg_count, ref mb, ref is_params_applicable) == 0;
if (arguments != null)
arg_count = arguments.Count;
if (!is_applicable && !params_method && arg_count != pd_count) {
ec.Report.Error (1593, loc, "Delegate `{0}' does not take `{1}' arguments",
TypeManager.CSharpName (del_type), arg_count.ToString ());
} else if (arguments == null || !arguments.HasDynamic) {
me.VerifyArgumentsCompat (ec, ref arguments, arg_count, mb,
is_params_applicable || (!is_applicable && params_method), false, loc);
}
type = method.ReturnType;
eclass = ExprClass.Value;
return this;
}