using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Microsoft.Research.DynamicDataDisplay.Common.UndoSystem { public sealed class CollectionAddAction : UndoAction { private readonly ICollection collection; private readonly T item; public CollectionAddAction(ICollection collection, T item) { if (collection == null) throw new ArgumentNullException("collection"); if (item == null) throw new ArgumentNullException("addedItem"); this.collection = collection; this.item = item; } public override void Do() { collection.Add(item); } public override void Undo() { collection.Remove(item); } } }