InitSynchronization() публичный статический Метод

Activate transaction synchronization for the current thread.
Called by transaction manager at the beginning of a transaction.
/// If synchronization is already active. ///
public static InitSynchronization ( ) : void
Результат void
        public void SynchronizationsExecuteInOrderOfRegistration()
        {
            TransactionSynchronizationManager.InitSynchronization();

            try
            {
                // expect syncs to be run A, B, C, D, E since all have order '1'
                TransactionSynchronizationManager.RegisterSynchronization(new Sync("A", 1));
                TransactionSynchronizationManager.RegisterSynchronization(new Sync("B", 1));
                TransactionSynchronizationManager.RegisterSynchronization(new Sync("C", 1));
                TransactionSynchronizationManager.RegisterSynchronization(new Sync("D", 1));
                TransactionSynchronizationManager.RegisterSynchronization(new Sync("E", 1));

                // simulate what APTM does
                Sync[] syncs = (Sync[])CollectionUtils.ToArray(TransactionSynchronizationManager.Synchronizations, typeof(Sync));
                Assert.AreEqual("A", syncs[0].Name);
                Assert.AreEqual("B", syncs[1].Name);
                Assert.AreEqual("C", syncs[2].Name);
                Assert.AreEqual("D", syncs[3].Name);
                Assert.AreEqual("E", syncs[4].Name);
            }
            finally
            {
                TransactionSynchronizationManager.ClearSynchronization();
            }
        }
        public void SynchronizationsLifeCycle()
        {
            TransactionSynchronizationManager.InitSynchronization();
            IList syncs = TransactionSynchronizationManager.Synchronizations;

            Assert.AreEqual(0, syncs.Count);
            TransactionSynchronizationManager.RegisterSynchronization(MockRepository.GenerateMock <ITransactionSynchronization>());
            syncs = TransactionSynchronizationManager.Synchronizations;
            Assert.AreEqual(1, syncs.Count);
            TransactionSynchronizationManager.ClearSynchronization();
        }
        public void SynchronizationsLifeCycle()
        {
            TransactionSynchronizationManager.InitSynchronization();
            IList syncs = TransactionSynchronizationManager.Synchronizations;

            Assert.AreEqual(0, syncs.Count);
            TransactionSynchronizationManager.RegisterSynchronization(new MockTxnSync());
            syncs = TransactionSynchronizationManager.Synchronizations;
            Assert.AreEqual(1, syncs.Count);
            TransactionSynchronizationManager.ClearSynchronization();
        }
 public void InitSynchronizationsInvalid()
 {
     TransactionSynchronizationManager.InitSynchronization();
     Assert.Throws <InvalidOperationException>(() => TransactionSynchronizationManager.InitSynchronization());
 }
 public void InitSynchronizationsInvalid()
 {
     TransactionSynchronizationManager.InitSynchronization();
     TransactionSynchronizationManager.InitSynchronization();
 }