Beispiel #1
0
            /// <summary>
            /// Enlist ourselves into the ambient transaction.
            /// </summary>
            public void Begin()
            {
                if (this.enlistedTransaction == null)
                {
                    if (Transaction.Current == null)
                    {
                        // no ambient transaction to enlist in
                        throw new InvalidOperationException(RM.Get_Error_CannotEnlistInNonTransactionalContext());
                    }

                    if (!Transaction.Current.EnlistPromotableSinglePhase(this))
                    {
                        // cannot enlist the adapter in a distributed transaction
                        throw new InvalidOperationException(RM.Get_Error_CannotEnlistInDistributedTransaction());
                    }
                }
                else if (Transaction.Current != this.enlistedTransaction)
                {
                    // cannot enlist an adapter in more than one transaction
                    throw new InvalidOperationException(RM.Get_Error_AdapterAlreadyEnlisted());
                }
            }