public override Edit Reverse() { switch (action) { case ListEditAction.ChangeItem: for (int i = 0; i < items.Count; i++) { T backup = items[i]; items[i] = list[i + startIndex]; list[i + startIndex] = backup; } break; case ListEditAction.AddItem: list.RemoveRange(startIndex, items.Count); action = ListEditAction.RemoveItem; break; case ListEditAction.RemoveItem: list.InsertRange(startIndex, items); action = ListEditAction.AddItem; break; } return(this); }
public ListRangeEdit(ListEditAction action, List <T> list, List <T> items, int startIndex) { this.action = action; this.list = list; this.items = items; this.startIndex = startIndex; }
public IListEdit(ListEditAction action, IList <T> list, T item, int index) { this.action = action; this.list = list; this.item = item; this.index = index; }
public override Edit Reverse() { switch (action) { case ListEditAction.ChangeItem: T backup = list[index]; list[index] = item; item = backup; break; case ListEditAction.AddItem: list.RemoveAt(index); action = ListEditAction.RemoveItem; break; case ListEditAction.RemoveItem: list.Insert(index, item); action = ListEditAction.AddItem; break; } return(this); }