private void PushServiceDomain(Transaction newCurrent)
{
if (((newCurrent == null) || !newCurrent.Equals(ContextUtil.SystemTransaction)) && ((newCurrent != null) || (ContextUtil.SystemTransaction != null)))
{
ServiceConfig cfg = new ServiceConfig();
try
{
if (newCurrent != null)
{
cfg.Synchronization = SynchronizationOption.RequiresNew;
ServiceDomain.Enter(cfg);
this.createdDoubleServiceDomain = true;
cfg.Synchronization = SynchronizationOption.Required;
cfg.BringYourOwnSystemTransaction = newCurrent;
}
ServiceDomain.Enter(cfg);
this.createdServiceDomain = true;
}
catch (COMException exception)
{
if (System.Transactions.Oletx.NativeMethods.XACT_E_NOTRANSACTION == exception.ErrorCode)
{
throw TransactionException.Create(System.Transactions.SR.GetString("TraceSourceBase"), System.Transactions.SR.GetString("TransactionAlreadyOver"), exception);
}
throw TransactionException.Create(System.Transactions.SR.GetString("TraceSourceBase"), exception.Message, exception);
}
finally
{
if (!this.createdServiceDomain && this.createdDoubleServiceDomain)
{
ServiceDomain.Leave();
}
}
}
}