Example #1
0
        /// <summary>
        /// Rollbacks the open transaction and invokes the regsitered undo operations.
        /// </summary>
        /// <exception cref="ActionInvokationException">An error occured while invoking the undo operations within the open transaction.</exception>
        public void RollbackTransactions()
        {
            if (!this.openTransactions.Any())
            {
                throw new InvalidOperationException("There is no open transaction available to roll back.");
            }

            IInvokableTransaction transaction = this.openTransactions.First();

            transaction.Rollback();
        }
Example #2
0
        /// <summary>
        /// Rollbacks the provided transaction.
        /// </summary>
        /// <param name="transaction">The transaction to roll back.</param>
        /// <exception cref="ArgumentNullException"><paramref name="transaction"/> is a <see langword="null"/> reference.</exception>
        /// <exception cref="ArgumentException">The <see cref="UndoManager"/> does not contain <paramref name="transaction"/>.</exception>
        /// <exception cref="ActionInvokationException">An error occured while invoking the undo operations within the transaction.</exception>
        void ITransactionManager.RollbackTransaction(IInvokableTransaction transaction)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }

            if (!this.openTransactions.Contains(transaction))
            {
                throw new ArgumentException("Can not find the transaction to roll back", "transaction");
            }

            while (this.openTransactions.Contains(transaction))
            {
                IInvokableTransaction toRollback = this.openTransactions.Pop();
                toRollback.Rollback();
            }
        }