/// <summary> /// 构造方法 /// </summary> /// <param name="pci"></param> /// <param name="sourceValue"></param> /// <param name="targetValue"></param> public ObjectPropertyCompareResult(PropertyCompareInfo pci, object sourceValue, object targetValue) { pci.NullCheck("pci"); this.PropertyName = pci.PropertyName; this.PropertyTypeName = pci.PropertyTypeName; this.SortID = pci.SortID; this.Description = pci.Description; this.OldValue = sourceValue; this.NewValue = targetValue; }
/// <summary> /// 填充属性的比较信息 /// </summary> /// <param name="type"></param> /// <param name="compareInfo"></param> private static void FillPropertiesCompareInfo(System.Type type, ObjectCompareInfo compareInfo) { PropertyInfo[] pis = type.GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo pi in pis) { AttributeHelper.GetCustomAttribute <PropertyCompareAttribute>(pi).IsNotNull(pca => { PropertyCompareInfo pci = new PropertyCompareInfo(); pci.PropertyName = pi.Name; if (pi.PropertyType != typeof(string)) { pci.PropertyTypeName = pi.PropertyType.AssemblyQualifiedName; } pca.CopyTo(pci); compareInfo.Properties.Add(pci); }); } }