public void AddToStack(IReversibleCommand reversibleCommand) { undoList.AddFirst(reversibleCommand); foreach (IReversibleCommand command in redoList) { command.DisposeRedo(); } redoList.Clear(); if (undoList.Count > MaxUndoCount) { IReversibleCommand removedCommand = undoList.Last.Value; undoList.RemoveLast(); removedCommand.DisposeUndo(); } }