public void SetTransaction(Transaction transaction) { lock (this.syncRoot) { if (transaction == null) { // transactions require failfasts to prevent corruption DiagnosticUtility.FailFast("Attempting to set transaction to NULL"); } if (this.currentTransaction == null) { ProxyEnlistment enlistment; enlistment = new ProxyEnlistment(this, transaction); transaction.EnlistVolatile(enlistment, EnlistmentOptions.None); this.currentTransaction = transaction; if (this.currentVoter != null) { this.currentVoter.SetTransaction(this.currentTransaction); } } else if (this.currentTransaction != transaction) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.TransactionMismatch()); } } }
private void ClearTransaction(ProxyEnlistment enlistment) { lock (this.syncRoot) { if (this.currentTransaction == null) { DiagnosticUtility.FailFast("Clearing inactive TransactionProxy"); } if (enlistment.Transaction != this.currentTransaction) { DiagnosticUtility.FailFast("Incorrectly working on multiple transactions"); } this.currentTransaction = null; this.currentVoter = null; } }