コード例 #1
0
        public static TranScope CreateNewTransactionScope()
        {
            var microCommandProvider = new MicroCommandTransitionProvider();
            var tranScope            = new TranScope(microCommandProvider);

            tranScope.Helper = new MicroCommandHelper(microCommandProvider);
            return(tranScope);
        }
コード例 #2
0
        public void Redo(int historyIndex)
        {
            if (!CanRedo())
            {
                throw new InvalidOperationException("Cannot redo!");
            }

            var curTran = _currentTransaction;

            _currentTransaction = null;             // no transaction at moment of redo
            DestroyTransaction(curTran);

            var nextNode = _currentNode.Children[historyIndex];

            foreach (var oneTransition in nextNode.Transitions)
            {
                oneTransition.ExecuteForward();
            }

            _currentNode = nextNode;

            CreateNewCurrentTransaction();
        }
コード例 #3
0
        public void Undo()
        {
            if (!CanUndo())
            {
                throw new InvalidOperationException("Cannot undo!");
            }

            var curTran = _currentTransaction;

            _currentTransaction = null;             // no transaction at moment of undo
            DestroyTransaction(curTran);

            var transitions = _currentNode.Transitions;

            for (int i = transitions.Count - 1; i >= 0; i--)
            {
                var oneTransition = transitions[i];
                oneTransition.ExecuteBackward();
            }

            _currentNode = _currentNode.Parent;

            CreateNewCurrentTransaction();
        }
コード例 #4
0
 private void DestroyTransaction(TranScope tran)
 {
     tran.TransactionCompleted -= TransactionCompleted;
     tran.Dispose();
 }
コード例 #5
0
 private void CreateNewCurrentTransaction()
 {
     _currentTransaction = TransationFactory.CreateNewTransactionScope();
     _currentTransaction.TransactionCompleted += TransactionCompleted;
 }