/// <summary> /// Unregisters a collection scope selected objects from the <see cref="SelectionService"/>. /// </summary> /// <param name="scope">The selection scope to unregister.</param> public void UnregisterSelectionScope([NotNull] SelectionScope scope) { if (scope == null) { throw new ArgumentNullException(nameof(scope)); } foreach (var collection in scope.Collections) { collection.CollectionChanged -= CollectionChanged; } scopes.Remove(scope); // Update history to let it know about this collection foreach (var operation in stack.RetrieveAllTransactions().SelectMany(x => x.Operations).OfType <SelectionOperation>()) { foreach (var collection in scope.Collections) { operation.UnregisterCollection(collection); } } // Also update the current state foreach (var collection in scope.Collections) { CurrentState.UnregisterCollection(collection); } }
/// <summary> /// Unregisters a collection from the previous and next states of this operation. /// </summary> /// <param name="collection">The collection to unregister.</param> public void UnregisterCollection([NotNull] INotifyCollectionChanged collection) { previousState.UnregisterCollection(collection); nextState.UnregisterCollection(collection); }