Rev | Line | |
---|
[12503] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 |
|
---|
| 6 | namespace Microsoft.Research.DynamicDataDisplay.Common.UndoSystem
|
---|
| 7 | {
|
---|
| 8 | public sealed class CollectionAddAction<T> : UndoAction
|
---|
| 9 | {
|
---|
| 10 | private readonly ICollection<T> collection;
|
---|
| 11 | private readonly T item;
|
---|
| 12 |
|
---|
| 13 | public CollectionAddAction(ICollection<T> collection, T item)
|
---|
| 14 | {
|
---|
| 15 | if (collection == null)
|
---|
| 16 | throw new ArgumentNullException("collection");
|
---|
| 17 | if (item == null)
|
---|
| 18 | throw new ArgumentNullException("addedItem");
|
---|
| 19 |
|
---|
| 20 | this.collection = collection;
|
---|
| 21 | this.item = item;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | public override void Do()
|
---|
| 25 | {
|
---|
| 26 | collection.Add(item);
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | public override void Undo()
|
---|
| 30 | {
|
---|
| 31 | collection.Remove(item);
|
---|
| 32 | }
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.