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 CollectionRemoveAction<T> : UndoAction
|
---|
| 9 | {
|
---|
| 10 | private readonly IList<T> collection;
|
---|
| 11 | private readonly T item;
|
---|
| 12 | private readonly int index;
|
---|
| 13 |
|
---|
| 14 | public CollectionRemoveAction(IList<T> collection, T item, int index)
|
---|
| 15 | {
|
---|
| 16 | if (collection == null)
|
---|
| 17 | throw new ArgumentNullException("collection");
|
---|
| 18 | if (item == null)
|
---|
| 19 | throw new ArgumentNullException("addedItem");
|
---|
| 20 |
|
---|
| 21 | this.collection = collection;
|
---|
| 22 | this.item = item;
|
---|
| 23 | this.index = index;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | public override void Do()
|
---|
| 27 | {
|
---|
| 28 | collection.Remove(item);
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | public override void Undo()
|
---|
| 32 | {
|
---|
| 33 | collection.Insert(index, item);
|
---|
| 34 | }
|
---|
| 35 | }
|
---|
| 36 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.