public override PropertyInfo SelectProperty (BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers)
{
if (match == null || match.Length == 0)
throw new ArgumentException ("No properties provided", "match");
bool haveRet = (returnType != null);
int idxlen = (indexes != null) ? indexes.Length : -1;
PropertyInfo result = null;
int i;
int best_score = Int32.MaxValue - 1;
int fail_score = Int32.MaxValue;
int level = 0;
for (i = match.Length - 1; i >= 0; i--) {
PropertyInfo p = match [i];
ParameterInfo[] args = p.GetIndexParameters ();
if (idxlen >= 0 && idxlen != args.Length)
continue;
if (haveRet && p.PropertyType != returnType)
continue;
int score = Int32.MaxValue - 1;
if (idxlen > 0) {
score = check_arguments_with_score (indexes, args);
if (score == -1)
continue;
}
int new_level = GetDerivedLevel (p.DeclaringType);
if (result != null) {
if (best_score < score)
continue;
if (best_score == score) {
if (level == new_level) {
// Keep searching. May be there's something
// better for us.
fail_score = score;
continue;
}
if (level > new_level)
continue;
}
}
result = p;
best_score = score;
level = new_level;
}
if (fail_score <= best_score)
throw new AmbiguousMatchException ();
return result;
}