Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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;
        }