public void NotifyValueWillBeRemoved <T>(ITrackableCollection <T> trackableCollection, T removed) { AssertNotLocked(); if (!_isEnabled) { return; } var list = trackableCollection as IList <T>; if (list != null) { var index = list.IndexOf(removed); if (index == -1) { return; } _changeHistory.Push(() => trackableCollection.InsertWithoutTracking(removed, index)); return; } if (trackableCollection.Contains(removed)) { _changeHistory.Push(() => trackableCollection.AddWithoutTracking(removed)); } }
public void NotifyCollectionWillBeCleared <T>(ITrackableCollection <T> trackableCollection) { AssertNotLocked(); if (!_isEnabled) { return; } var elements = trackableCollection.ToList(); if (elements.Count == 0) { return; } _changeHistory.Push(() => { foreach (var element in elements) { trackableCollection.AddWithoutTracking(element); } }); }