Esempio n. 1
0
        public void Undo()
        {
            if (_mementos.Count == 0)
            {
                return;
            }

            var memento = _mementos.Last();

            _mementos.Remove(memento);

            try
            {
                _originator.Restore(memento);
            }
            catch (Exception)
            {
                Undo();
            }
        }
Esempio n. 2
0
        // Order to restore a previous state.
        public void Undo()
        {
            if (_mementoes.Count == 0)
            {
                return;
            }

            var memento = _mementoes.Last();

            _mementoes.Remove(memento);

            try
            {
                _originator.Restore(memento);
            }
            catch (Exception e)
            {
                // If an exception occurs, try again with the next memento.
                Console.WriteLine(e);
                Undo();
            }
        }
Esempio n. 3
0
 public void Undo()
 {
     originator.Restore(history.Last());
     history.RemoveAt(history.Count - 1);
 }