public SelectionScope RegisterSelectionScope([NotNull] Func <AbsoluteId, object> idToObject, [NotNull] Func <object, AbsoluteId?> objectToId, [NotNull] params INotifyCollectionChanged[] collections) { if (idToObject == null) { throw new ArgumentNullException(nameof(idToObject)); } if (objectToId == null) { throw new ArgumentNullException(nameof(objectToId)); } if (collections == null) { throw new ArgumentNullException(nameof(collections)); } var scope = new SelectionScope(collections, idToObject, objectToId); foreach (var collection in scope.Collections) { collection.CollectionChanged += CollectionChanged; } scopes.Add(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.RegisterCollection(scope, collection); } } // Also update the current state foreach (var collection in scope.Collections) { CurrentState.RegisterCollection(scope, collection); } return(scope); }
/// <summary> /// Registers a collection to the previous and next states of this operation. /// </summary> /// <param name="scope"></param> /// <param name="collection">The collection to register.</param> public void RegisterCollection([NotNull] SelectionScope scope, [NotNull] INotifyCollectionChanged collection) { previousState.RegisterCollection(scope, collection); nextState.RegisterCollection(scope, collection); }