示例#1
0
        /// <summary>
        ///    Removes and executes an <see cref="IUndoableAction"/> beginning from the top of undo stack
        ///    till the rollback point is reached.
        /// </summary>
        /// <exception cref="ArgumentException">
        ///   Undo stack doesn't contain <see cref="IRollbackPoint"/>.
        /// </exception>
        public void RollbackTo(IRollbackPoint toPoint)
        {
            Check.Requires(
                ContainsRollbackPoint(toPoint),
                ExceptionTexts.RollbackPointNotFound
                );
            _rollbackPoints.Remove(toPoint);
            _undoing = true;
            IUndoableAction action;

            action = _actionStack.Pop();
            while (!Object.ReferenceEquals(action, toPoint))
            {
                action.Undo();
                action = _actionStack.Pop();
            }
            _actionStack.Push(action);
            _undoing = false;
        }
示例#2
0
        public void RollbackTo_WhenCollectionLoadedAfterRollbackPoint_DoesNotClearCollection()
        {
            Employee employee = new Employee();

            employee.Projects.Add(new Project());

            EmployeeVM.InitializeFrom(employee);

            IRollbackPoint rollbackPoint = EmployeeVM.UndoManager.GetRollbackPoint();

            ViewModelAssert.IsNotLoaded(EmployeeVM, x => x.Projects);
            EmployeeVM.Load(x => x.Projects);
            Assert.AreEqual(1, EmployeeVM.Projects.Count);

            EmployeeVM.UndoManager.RollbackTo(rollbackPoint);

            ViewModelAssert.IsLoaded(EmployeeVM, x => x.Projects);
            Assert.AreEqual(1, EmployeeVM.Projects.Count);
        }
示例#3
0
 public void RollbackTo(IRollbackPoint point)
 {
     Kernel.UndoManager.RollbackTo(point);
 }
示例#4
0
 public bool ContainsRollbackPoint(IRollbackPoint point)
 {
     Check.NotNull(point, nameof(point));
     return(_actionStack.Contains(point));
 }