internal void SetActive() { EnableEngineProtection(); PSTransaction transaction = this.transactionStack.Peek(); if (transaction == null) { throw new InvalidOperationException(TransactionStrings.NoTransactionForActivation); } if (transaction.IsRolledBack) { throw new TransactionAbortedException(TransactionStrings.NoTransactionForActivationBecauseRollback); } this.previousActiveTransaction = Transaction.Current; transaction.Activate(); }
/// <summary> /// Activates the current transaction, both in the engine, and in the Ambient. /// </summary> /// internal void SetActive() { PSTransactionManager.EnableEngineProtection(); PSTransaction currentTransaction = _transactionStack.Peek(); // Should not be able to activate a transaction that is not active if (currentTransaction == null) { string error = TransactionStrings.NoTransactionForActivation; throw new InvalidOperationException(error); } // If you are already in a transaction that has been aborted, you should // not be able to activate it. if (currentTransaction.IsRolledBack) { string error = TransactionStrings.NoTransactionForActivationBecauseRollback; throw new TransactionAbortedException(error); } _previousActiveTransaction = Transaction.Current; currentTransaction.Activate(); }