public void CleanUp() { foreach (ModelItem modelItem in TrackedModelItem.Keys) { modelItem.PropertyChanged -= new ComponentModel.PropertyChangedEventHandler(modelItem_PropertyChanged); } TrackedModelItem.Clear(); foreach (INotifyCollectionChanged collection in TrackedCollection) { collection.CollectionChanged -= new Collections.Specialized.NotifyCollectionChangedEventHandler(collection_CollectionChanged); } TrackedCollection.Clear(); //remove childViewModels foreach (TreeViewItemViewModel child in ChildViewModels) { this.Parent.InternalChildren.Remove(child); child.CleanUp(); } this.ChildViewModels.Clear(); }
public void Undo_WhenCalledAfterClear_RevertsClear() { TrackedCollection <int> tc = new TrackedCollection <int>(CollectionTrackingStrategy.TrackOnlyCollectionOperations); tc.Tracker.Track(); tc.Add(0); tc.Add(1); tc.Add(2); tc.Clear(); Assert.IsTrue(tc.Count == 0); tc.Tracker.Undo(); Assert.IsTrue(tc.Count == 3); Assert.IsTrue(tc[0] == 0); Assert.IsTrue(tc[1] == 1); Assert.IsTrue(tc[2] == 2); }
public void Undo_WhenCalledAfterClear_RevertsClear() { TrackedCollection<int> tc = new TrackedCollection<int>(CollectionTrackingStrategy.TrackOnlyCollectionOperations); tc.Tracker.Track(); tc.Add(0); tc.Add(1); tc.Add(2); tc.Clear(); Assert.IsTrue(tc.Count == 0); tc.Tracker.Undo(); Assert.IsTrue(tc.Count == 3); Assert.IsTrue(tc[0] == 0); Assert.IsTrue(tc[1] == 1); Assert.IsTrue(tc[2] == 2); }