/// <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();
        }
Exemple #2
0
 internal PSTransactionContext(Internal.PSTransactionManager transactionManager)
 {
 }
 internal PSTransactionContext(PSTransactionManager transactionManager)
 {
     this.transactionManager = transactionManager;
     transactionManager.SetActive();
 }