public virtual AuditedProperty AuditProperty(PropertyInfo property, object oldValue, object newValue) { var value = new AuditedProperty(property.Name) { DisplayName = property.Name.SplitUpperCaseToString(), ShortDisplayName = property.Name.SplitUpperCaseToString(), OldValue = GetPropertyValue(oldValue), NewValue = GetPropertyValue(newValue) }; return(value); }
public override AuditedProperty AuditProperty(PropertyInfo property, object oldValue, object newValue) { var auditedProperty = new AuditedProperty(property.Name); var attributes = new List <Attribute>(property.GetCustomAttributes(true).OfType <Attribute>()); var dataTypeAttribute = attributes.OfType <DataTypeAttribute>().FirstOrDefault(); var displayFormatAttribute = attributes.OfType <DisplayFormatAttribute>().FirstOrDefault(); if (displayFormatAttribute == null && dataTypeAttribute != null) { displayFormatAttribute = dataTypeAttribute.DisplayFormat; } var displayAttribute = attributes.OfType <DisplayAttribute>().FirstOrDefault(); auditedProperty.DisplayName = property.Name.SplitUpperCaseToString(); if (displayAttribute != null) { auditedProperty.ShortDisplayName = displayAttribute.GetShortName(); auditedProperty.DisplayName = displayAttribute.GetName(); } else { var displayNameAttribute = attributes.OfType <DisplayNameAttribute>().FirstOrDefault(); if (displayNameAttribute != null) { auditedProperty.DisplayName = displayNameAttribute.DisplayName; } } auditedProperty.OldValue = GetPropertyValue(displayFormatAttribute, oldValue); auditedProperty.NewValue = GetPropertyValue(displayFormatAttribute, newValue); return(auditedProperty); }