Пример #1
0
        /// <summary>
        /// Determines whether action is included in given enumeration.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="existingActions">The existing actions.</param>
        /// <returns><c>true</c> if action is included; otherwise, <c>false</c>.</returns>
        private bool isIncludedIn(TransactionAction action, IEnumerable <TransactionAction> existingActions)
        {
            foreach (var existingAction in existingActions)
            {
                if (action.IsIncludedIn(existingAction))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        /// <summary>
        /// Determines whether action is included in transaction.
        /// </summary>
        /// <param name="coveringAction">The action that is tested for action cover.</param>
        /// <returns><c>true</c> if action is included false; otherwise, <c>false</c>.</returns>
        internal bool IsIncludedIn(TransactionAction coveringAction)
        {
            //incompatible keys
            if (_keys.Length != coveringAction._keys.Length)
            {
                return(false);
            }

            //different keys
            for (var i = 0; i < _keys.Length; ++i)
            {
                if (!_keys[i].Equals(coveringAction._keys[i]))
                {
                    return(false);
                }
            }

            return(_predicate(coveringAction));
        }
Пример #3
0
        /// <summary>
        /// Attach after action to given transaction. After action
        /// will be executed after transaction commit.
        /// </summary>
        /// <param name="transaction">The transaction.</param>
        /// <param name="afterAction">The after action.</param>
        public void AttachAfterAction(Transaction transaction, TransactionAction afterAction)
        {
            if (transaction == null)
            {
                if (!isIncludedIn(afterAction, _rootActions))
                {
                    _rootActions.Enqueue(afterAction);
                }

                tryRunRootActions();
            }
            else
            {
                var actions = _activeTransactions[transaction];
                if (!isIncludedIn(afterAction, actions))
                {
                    actions.Add(afterAction);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Add action that will be executed after ending of current transaction. But not necessary immediately.
        /// If action is already included it will be not fired. If it includes another actions
        /// it will flush them.
        /// </summary>
        /// <param name="afterAction">After action</param>
        public void AddAfterAction(TransactionAction afterAction)
        {
            ensureRunning();

            _manager.AttachAfterAction(this, afterAction);
        }