/// <summary> /// Registers the collection and automatically. As soon as the <see cref="INotifyCollectionChanged.CollectionChanged"/> event /// occurs, it will automatically create a backup of the collection to support undo. /// </summary> /// <param name="collection">The collection.</param> /// <param name="tag">The tag.</param> /// <exception cref="ArgumentNullException">The <paramref name="collection"/> is <c>null</c>.</exception> public void RegisterCollection(INotifyCollectionChanged collection, object tag = null) { Argument.IsNotNull("collection", collection); Log.Debug("Registering collection of type '{0}' with tag '{1}'", collection.GetType().Name, TagHelper.ToString(tag)); if (!_observers.ContainsKey(collection)) { _observers[collection] = new CollectionObserver(collection, tag, this); Log.Debug("Registered collection"); } else { Log.Debug("Collection already registered, not registered"); } }