public static DataMemberAttribute GetDataMemberAttribute(MemberInfo memberInfo) { // DataMemberAttribute does not have inheritance // can't override a field if (memberInfo.MemberType() == MemberTypes.Field) { return(CachedAttributeGetter <DataMemberAttribute> .GetAttribute(memberInfo)); } // search property and then search base properties if nothing is returned and the property is virtual PropertyInfo propertyInfo = (PropertyInfo)memberInfo; DataMemberAttribute result = CachedAttributeGetter <DataMemberAttribute> .GetAttribute(propertyInfo); if (result == null) { if (propertyInfo.IsVirtual()) { Type currentType = propertyInfo.DeclaringType; while (result == null && currentType != null) { PropertyInfo baseProperty = (PropertyInfo)ReflectionUtils.GetMemberInfoFromType(currentType, propertyInfo); if (baseProperty != null && baseProperty.IsVirtual()) { result = CachedAttributeGetter <DataMemberAttribute> .GetAttribute(baseProperty); } currentType = currentType.BaseType(); } } } return(result); }