/// <summary> /// 分析变动实体的变动属性 /// </summary> /// <param name="difference"></param> /// <returns></returns> private ChangeEntryPropertys ResolveChangeEntryPropertys(Difference difference) { ChangeEntryPropertys change = new ChangeEntryPropertys(); change.NewestValue = difference.Object2Value; change.OriginalValue = difference.Object1Value; change.Name = difference.PropertyName.Substring(difference.PropertyName.LastIndexOf(".") + 1); return(change); }
public IChangeManager Create(ComparisonResult comparisonResult) { changeManager.ClearChanger(); if (comparisonResult.AreEqual) { return(changeManager); } //根据实体与快照的差异进行分析实体的变动 foreach (var difference in comparisonResult.Differences) { ChangeEntry change = this.ResolveChangeEntry(difference); if (change.Type == ChangeEntryType.Addition || change.Type == ChangeEntryType.Remove) { this.changeManager.AddChanger(change); if (change.Type == ChangeEntryType.Addition) { //如果为新增类型,需要进一步分析实体中的值对象 var values = this.ResolveChangeObjectValue(change); foreach (var item in values) { this.changeManager.AddChanger(item); } } } else { var change2 = this.changeManager.GetChanger(change.NewestEntry); if (change2 == null) { this.changeManager.AddChanger(change); change2 = change; } //解析修改的字段 ChangeEntryPropertys changeProperty = this.ResolveChangeEntryPropertys(difference); change2.ChangePropertys.Add(changeProperty); } } return(changeManager); }