public static void Do <T>(this UndoRedoState <T> undoRedoState, IEnumerable <T> items) { Assert.IsNotNull(undoRedoState); Assert.IsNotNull(items); var unprocessedItemCount = undoRedoState.GetUnprocessedItemCount(); if (unprocessedItemCount > 0) { undoRedoState.Items.RemoveRange(undoRedoState.ProcessedItemCount, unprocessedItemCount); } var itemList = items.ToList(); undoRedoState.Items.AddRange(itemList); undoRedoState.ProcessedItemCount += itemList.Count; }
public static void Redo <T>(this UndoRedoState <T> undoRedoState, int itemCount, Action <IReadOnlyList <T> > process) { Assert.IsNotNull(undoRedoState); Assert.IsInRange(itemCount > 0); Assert.IsNotNull(process); var unprocessedItemCount = undoRedoState.GetUnprocessedItemCount(); if (unprocessedItemCount < itemCount) { throw new InvalidOperationException("Nincs meg a megadott számú ismételhető művelet."); } var items = undoRedoState.Items.GetRange(undoRedoState.ProcessedItemCount, itemCount).ToList(); process(items); undoRedoState.ProcessedItemCount += itemCount; }