コード例 #1
0
        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());
            }
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
 protected static async Task <TResult> ExecuteOperation <TResult>(IRollbackableOperation <TResult> operation)
 {
     if (IsInTransaction())
     {
         await EnlistOperation(operation);
     }
     else
     {
         await operation.Execute();
     }
     return(operation.Result);
 }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        /// <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);
        }