public DiffReport Compare(object object1, object object2, ComparerSettings settings) { var report = new DiffReport(); compare(object1, object2, settings, report); return(report); }
public void CompareObjects(object object1, object object2, ComparerSettings comparerSettings, DiffReport report, object commonAncestor) { var comparison = new Comparison <TObject>( object1.DowncastTo <TObject>(), object2.DowncastTo <TObject>(), comparerSettings, report, commonAncestor ); Compare(comparison); }
private void compare(object x1, object x2, ComparerSettings settings, DiffReport report, object commonAncestor = null) { //If both null return true if (x1 == null && x2 == null) { return; } //Check if one of them is null if (x1 == null || x2 == null) { var missingObject = x1 ?? x2; report.Add(new MissingDiffItem { Object1 = x1, Object2 = x2, MissingObject1 = x1, MissingObject2 = x2, MissingObjectType = _objectTypeResolver.TypeFor(missingObject), Description = Captions.Diff.OneObjectIsNull, CommonAncestor = commonAncestor }); return; } var type1 = x1.GetType(); var type2 = x2.GetType(); if (type1 != type2) { report.Add(new MismatchDiffItem { Object1 = x1, Object2 = x2, Description = Captions.Diff.DifferentTypes(_objectTypeResolver.TypeFor(x1), _objectTypeResolver.TypeFor(x2)), CommonAncestor = commonAncestor }); return; } var diffBuilder = _diffBuilderRepository.DiffBuilderFor(type1); diffBuilder?.CompareObjects(x1, x2, settings, report, commonAncestor); }