private static object[] GetCustomAttributes(MemberInfo memberInfo, Type type, bool inherit)
{
if (memberInfo.MemberType == MemberTypes.Property && inherit)
{
var list = new ArrayList();
var propertyInfo = (PropertyInfo) memberInfo;
while (true)
{
// LAMESPEC: Why the hell isn't AddRange part of ArrayList and not IList?
list.AddRange(propertyInfo.GetCustomAttributes(type, false));
if (propertyInfo.DeclaringType.BaseType == null)
{
break;
}
//if (propertyInfo.GetGetMethod().IsVirtual || propertyInfo.GetSetMethod().IsVirtual)
{
propertyInfo = propertyInfo.DeclaringType.BaseType.GetProperty(propertyInfo.Name);
if (propertyInfo == null)
{
break;
}
}
}
return list.ToArray();
}
else
{
return memberInfo.GetCustomAttributes(type, inherit);
}
}