public static FakeRelationChange Merge(FakeRelationChange first, FakeRelationChange second) { if (first == null) { return(second); } if (second == null) { return(first); } /* * The merging rules are the following (revision types of the first and second changes): * - DEL, DEL - return any (the work units are the same) * - DEL, ADD - return ADD (points to new owner) * - ADD, DEL - return ADD (points to new owner) * - ADD, ADD - return second (points to newer owner) */ if (first.RevisionType == RevisionType.DEL || second.RevisionType == RevisionType.ADD) { return(second); } else { return(first); } }
public override IAuditWorkUnit Merge(FakeBidirectionalRelationWorkUnit second) { // First merging the nested work units. var mergedNested = second.NestedWorkUnit.Dispatch(NestedWorkUnit); // Now merging the fake relation changes from both work units. var secondFakeRelationChanges = second.fakeRelationChanges; var mergedFakeRelationChanges = new Dictionary <string, FakeRelationChange>(); var allPropertyNames = new HashSet <string>(fakeRelationChanges.Keys); allPropertyNames.UnionWith(secondFakeRelationChanges.Keys); foreach (var propertyName in allPropertyNames) { mergedFakeRelationChanges.Add(propertyName, FakeRelationChange.Merge( fakeRelationChanges[propertyName], secondFakeRelationChanges[propertyName])); } return(new FakeBidirectionalRelationWorkUnit(this, mergedFakeRelationChanges, mergedNested)); }
public override IAuditWorkUnit Merge(FakeBidirectionalRelationWorkUnit second) { // First merging the nested work units. IAuditWorkUnit mergedNested = second.getNestedWorkUnit().Dispatch(nestedWorkUnit); // Now merging the fake relation changes from both work units. IDictionary <String, FakeRelationChange> secondFakeRelationChanges = second.getFakeRelationChanges(); IDictionary <String, FakeRelationChange> mergedFakeRelationChanges = new Dictionary <String, FakeRelationChange>(); //TODO Simon - decide if we use IESI.Collections in the end. ISet <String> allPropertyNames = new HashedSet <String>(fakeRelationChanges.Keys); allPropertyNames.AddAll(secondFakeRelationChanges.Keys); foreach (String propertyName in allPropertyNames) { mergedFakeRelationChanges.Add(propertyName, FakeRelationChange.Merge( fakeRelationChanges[propertyName], secondFakeRelationChanges[propertyName])); } return(new FakeBidirectionalRelationWorkUnit(this, mergedFakeRelationChanges, mergedNested)); }
public static FakeRelationChange Merge(FakeRelationChange first, FakeRelationChange second) { if (first == null) { return second; } if (second == null) { return first; } /* * The merging rules are the following (revision types of the first and second changes): * - DEL, DEL - return any (the work units are the same) * - DEL, ADD - return ADD (points to new owner) * - ADD, DEL - return ADD (points to new owner) * - ADD, ADD - return second (points to newer owner) */ if (first.revisionType == RevisionType.Deleted || second.revisionType == RevisionType.Added) { return second; } return first; }