private int GetAppropriateMethodCount(Type type, string methodName, bool staticAccess, Expression[] args, out MethodBase method)
{
BindingFlags flags = BindingFlags.Public | BindingFlags.DeclaredOnly | (staticAccess ? BindingFlags.Static : BindingFlags.Instance)
| BindingFlags.IgnoreCase;
foreach (MemberInfo[] members in SelfAndBaseTypes(type).Select(t => t.GetMethods(flags)))
{
int count = FindBestMethod(members.Cast<MethodBase>(), methodName, args, out method);
if (count != 0) return count;
}
method = null;
return 0;
}