コード例 #1
0
        internal void Commit(SimpleTransaction tx)
        {
            tx.MakeInactive();
            var parent = tx.parent;

            // Unlock all resources held by this transaction
            if (parent != null)
            {
                parent.MakeActive();
            }
            _currentTransaction[tx.provider] = parent;

            // Fire Events and unlock Store only when  Top-most Tx commits
            if (parent == null)
            {
                SimpleLockManager.UnlockAll(tx);
                tx.FireCompleted();
            }
        }
コード例 #2
0
        internal void Rollback(SimpleTransaction tx)
        {
            tx.MakeInactive();
            var parent = tx.parent;

            // Unlock all resources held by this transaction
            if (parent != null)
            {
                parent.MakeActive();
            }
            _currentTransaction[tx.provider] = parent;

            // Unlock Store only when Top-most Tx Completes
            if (parent == null)
            {
                SimpleLockManager.UnlockAll(tx);
            }

            // In case of Rollback we fire off event even for nested Tx
            tx.FireCompleted();
        }
コード例 #3
0
        internal SimpleTransaction BeginTransaction(
            VanillaXmlModelProvider provider, string name, SimpleTransaction parent, object userState)
        {
            var tx = new SimpleTransaction(provider, name, parent, this, userState);

            if (parent != null)
            {
                // Unsubscribe events on parent transaction
                parent.MakeInactive();

                // Create SimpleTransactionLogger for each document in VanillaXmlModelProvider
                foreach (var model in provider.OpenXmlModels)
                {
                    tx.EnlistResource(model as SimpleXmlModel);
                }
            }
            else
            {
                // This is the top level transaction, so acquire all locks to avoid deadlocks
                lock (this)
                {
                    foreach (var model in provider.OpenXmlModels)
                    {
                        tx.LockForWrite(model as SimpleXmlModel);
                    }
                }
            }

            // Make this the current Active transaction
            SetCurrentTransaction(provider, tx);
            tx.MakeActive();

            return tx;
        }