public static TranScope CreateNewTransactionScope() { var microCommandProvider = new MicroCommandTransitionProvider(); var tranScope = new TranScope(microCommandProvider); tranScope.Helper = new MicroCommandHelper(microCommandProvider); return(tranScope); }
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(); }
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(); }
private void DestroyTransaction(TranScope tran) { tran.TransactionCompleted -= TransactionCompleted; tran.Dispose(); }
private void CreateNewCurrentTransaction() { _currentTransaction = TransationFactory.CreateNewTransactionScope(); _currentTransaction.TransactionCompleted += TransactionCompleted; }