private Transaction InitTransaction(Transaction tx, TransactionScopeOption scopeOption)
        {
            if (tx != null)
            {
                return tx;
            }

            if (scopeOption == TransactionScopeOption.Suppress)
            {
                if (Transaction.CurrentInternal != null)
                {
                    this.parentScope = Transaction.CurrentInternal.Scope;
                }
                return null;
            }

            if (scopeOption == TransactionScopeOption.Required)
            {
                if (Transaction.CurrentInternal == null)
                {
                    this.isRoot = true;
                    return new Transaction();
                }

                this.parentScope = Transaction.CurrentInternal.Scope;
                return Transaction.CurrentInternal;
            }

            /* RequiresNew */
            if (Transaction.CurrentInternal != null)
            {
                this.parentScope = Transaction.CurrentInternal.Scope;
            }
            this.isRoot = true;
            return new Transaction();
        }
Пример #2
0
        internal void InitScope(TransactionScope scope)
        {
            /* See test NestedTransactionScope10 */
            this.CheckAborted();

            /* See test ExplicitTransaction6a */
            if (this.committed)
            {
                throw new InvalidOperationException("Commit has already been called on this transaction.");
            }

            this.Scope = scope;
        }