private void EnlistOperation(IRollbackableOperation operation) { Transaction tx = Transaction.Current; TxEnlistment enlistment; lock (this.enlistmentsLock) { if (this.enlistments == null) { this.enlistments = new Dictionary <string, TxEnlistment>(); } if (!this.enlistments.TryGetValue(tx.TransactionInformation.LocalIdentifier, out enlistment)) { enlistment = new TxEnlistment(tx); this.enlistments.Add(tx.TransactionInformation.LocalIdentifier, enlistment); } if (operation is IBackupableOperation) { ((IBackupableOperation)operation).BackupFolder = this.TempFolder; } enlistment.EnlistOperation(operation); this.journal = new List <IRollbackableOperation>(); this.journal.AddRange(enlistment.GetJournal()); } }
private static async Task EnlistOperation(IRollbackableOperation operation) { var transaction = Transaction.Current; await EnlistmentsLock.WaitAsync(); try { if (_enlistments == null) { _enlistments = new Dictionary <string, TransactionEnlistment>(); } if (!_enlistments.TryGetValue(transaction.TransactionInformation.LocalIdentifier, out var enlistment)) { enlistment = new TransactionEnlistment(transaction); _enlistments.Add(transaction.TransactionInformation.LocalIdentifier, enlistment); } await enlistment.EnlistOperation(operation); } finally { EnlistmentsLock.Release(); } }
protected static async Task <TResult> ExecuteOperation <TResult>(IRollbackableOperation <TResult> operation) { if (IsInTransaction()) { await EnlistOperation(operation); } else { await operation.Execute(); } return(operation.Result); }
private static void EnlistOperation(IRollbackableOperation operation) { var tx = Transaction.Current; lock (EnlistmentsLock) { if (_enlistments == null) { _enlistments = new Dictionary <string, TxEnlistment>(); } if (!_enlistments.TryGetValue(tx.TransactionInformation.LocalIdentifier, out var enlistment)) { enlistment = new TxEnlistment(tx); _enlistments.Add(tx.TransactionInformation.LocalIdentifier, enlistment); } enlistment.EnlistOperation(operation); } }
/// <summary> /// Enlists <paramref name="operation"/> in its journal, so it will be committed or rolled /// together with the other enlisted operations. /// </summary> /// <param name="operation"></param> public async Task EnlistOperation(IRollbackableOperation operation) { await operation.Execute(); _journal.Add(operation); }
/// <summary> /// Enlists <paramref name="operation"/> in its journal, so it will be committed or rolled back /// together with the other enlisted operations. /// </summary> /// <param name="operation"></param> public void EnlistOperation(IRollbackableOperation operation) { operation.Execute(); _journal.Add(operation); }
private static void EnlistOperation(IRollbackableOperation operation) { Transaction tx = Transaction.Current; TxEnlistment enlistment; lock (_enlistmentsLock) { if (_enlistments == null) { _enlistments = new Dictionary<string, TxEnlistment>(); } if (!_enlistments.TryGetValue(tx.TransactionInformation.LocalIdentifier, out enlistment)) { enlistment = new TxEnlistment(tx); _enlistments.Add(tx.TransactionInformation.LocalIdentifier, enlistment); } enlistment.EnlistOperation(operation); } }
/// <summary> /// Enlists <paramref name="operation"/> in its journal, so it will be committed or rolled /// together with the other enlisted operations. /// </summary> /// <param name="operation"></param> public void EnlistOperation(IRollbackableOperation operation) { operation.Execute(); journal.Add(operation); }