private TxEnlistment GetEnlistment()
{
Transaction tx = Transaction.Current;
TxEnlistment enlistment;
if (TxEnabled && tx != null)
{
lock (_enlistmentsLock)
{
if (_enlistments == null)
{
_enlistments = new Dictionary<string, TxEnlistment>();
}
if (_enlistments.ContainsKey(tx.TransactionInformation.LocalIdentifier))
{
enlistment = _enlistments[tx.TransactionInformation.LocalIdentifier];
}
else
{
enlistment = new TxEnlistment(tx);
enlistment.IgnoreExceptionsInRollback = IgnoreExceptionsInRollback;
_enlistments.Add(tx.TransactionInformation.LocalIdentifier, enlistment);
}
}
}
else
{
enlistment = new TxEnlistment();
}
return enlistment;
}