public static Merge ( |
||
left | ||
right | ||
Résultat |
public static ListDiff Merge(ListDiff left, ListDiff right) { List <int> keys = left.Operations.Keys.ToList <int>(); foreach (var kv in right.Operations) { if (!left.Operations.ContainsKey(kv.Key)) { keys.Add(kv.Key); } } ListDiff diff = new ListDiff(); foreach (int key in keys) { if (left.Operations.ContainsKey(key) && right.Operations.ContainsKey(key)) { diff.Operations[key] = DiffOperation.Merge(left.Operations[key], right.Operations[key]); } else if (left.Operations.ContainsKey(key)) { diff.Operations[key] = left.Operations[key]; } else if (right.Operations.ContainsKey(key)) { diff.Operations[key] = right.Operations[key]; } } return(diff); }
public static CompoundDiff Merge(CompoundDiff left, CompoundDiff right) { // Find combined key list List <object> keys = left.Operations.Keys.ToList <object>(); foreach (var kv in right.Operations) { if (!left.Operations.ContainsKey(kv.Key)) { keys.Add(kv.Key); } } // Merge the operations for each key. CompoundDiff diff = new CompoundDiff(); foreach (object key in keys) { if (left.Operations.ContainsKey(key) && right.Operations.ContainsKey(key)) { diff.Operations[key] = DiffOperation.Merge(left.Operations[key], right.Operations[key]); } else if (left.Operations.ContainsKey(key)) { diff.Operations[key] = left.Operations[key]; } else if (right.Operations.ContainsKey(key)) { diff.Operations[key] = right.Operations[key]; } } return(diff); }