System.Transactions.TransactionState.AddVolatileEnlistment C# (CSharp) Method

AddVolatileEnlistment() protected method

protected AddVolatileEnlistment ( VolatileEnlistmentSet &enlistments, Enlistment enlistment ) : void
enlistments VolatileEnlistmentSet
enlistment Enlistment
return void
        protected void AddVolatileEnlistment(ref VolatileEnlistmentSet enlistments, Enlistment enlistment)
        {
            // Grow the enlistment array if necessary.
            if (enlistments._volatileEnlistmentCount == enlistments._volatileEnlistmentSize)
            {
                InternalEnlistment[] newEnlistments =
                    new InternalEnlistment[enlistments._volatileEnlistmentSize + InternalTransaction.VolatileArrayIncrement];

                if (enlistments._volatileEnlistmentSize > 0)
                {
                    Array.Copy(
                        enlistments._volatileEnlistments,
                        newEnlistments,
                        enlistments._volatileEnlistmentSize
                        );
                }

                enlistments._volatileEnlistmentSize += InternalTransaction.VolatileArrayIncrement;
                enlistments._volatileEnlistments = newEnlistments;
            }

            // Add a new element to the end of the list
            enlistments._volatileEnlistments[enlistments._volatileEnlistmentCount] = enlistment.InternalEnlistment;
            enlistments._volatileEnlistmentCount++;

            // Make it's state active.
            VolatileEnlistmentState.VolatileEnlistmentActive.EnterState(
                enlistments._volatileEnlistments[enlistments._volatileEnlistmentCount - 1]);
        }