private static MethodInfo GetPropertyMethodFromBaseType(PropertyInfo propertyInfo, bool isGetter)
{
// we only invoke this when the propertyInfo does not have a GET or SET method on it
Type currentType = propertyInfo.DeclaringType.GetTypeInfo().BaseType;
PropertyInfo currentProperty;
string propertyName = propertyInfo.Name;
MethodInfo result = null;
while (currentType != null)
{
currentProperty = currentType.GetProperty(propertyName);
if (currentProperty != null)
{
if (isGetter)
{
result = currentProperty.GetMethod;
}
else
{
result = currentProperty.SetMethod;
}
if (result != null)
{
// we found the GetMethod/SetMethod on the type closest to the current declaring type
break;
}
}
// keep looking at the base type like compiler does
currentType = currentType.GetTypeInfo().BaseType;
}
return result;
}