public void Add(IDiffObject obj) { if (obj != null) { //clone the object so we don't modify objects that are being themselves diffed IDiffObject clone = obj.Clone(); int n = Items.Count; if (!_allowMerges || n == 0 || !Items[n - 1].Merge(clone)) { //if the collection is empty or if we couldn't merge the last element to the new object Items.Add(clone); } } }
public void Push(IDiffObject obj) { if (obj != null) { //clone the object so we don't modify objects that are being themselves diffed IDiffObject clone = obj.Clone(); if (_allowMerges && Items.Count > 0 && clone.Merge(Items[0])) { Items[0] = clone; } else { //there are no elements in the collection or we couldn't merge with the first Items.Insert(0, clone); } } }