当前位置: 首页>>代码示例>>C#>>正文


C# EnlistmentOptions.ToString方法代码示例

本文整理汇总了C#中EnlistmentOptions.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# EnlistmentOptions.ToString方法的具体用法?C# EnlistmentOptions.ToString怎么用?C# EnlistmentOptions.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EnlistmentOptions的用法示例。


在下文中一共展示了EnlistmentOptions.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DurableEnlistmentNotification

        protected DurableEnlistmentNotification(Guid resourceManager,
                                                EnlistmentOptions enlistmentOptions)
        {
            Trace.WriteIf(Tracing.Is.TraceVerbose, "resourceManager={0} enlistmentOptions={1}".FormatWith(resourceManager, enlistmentOptions.ToString("G")));
            Operation = new Operation(resourceManager);
            if (null == Transaction.Current)
            {
                throw new InvalidOperationException("There is no transaction scope to enlist with.");
            }

            Transaction.Current.EnlistDurable(resourceManager, this, enlistmentOptions);
            Transaction.Current.TransactionCompleted += OnTransactionCompleted;
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:13,代码来源:DurableEnlistmentNotification.cs

示例2: TransactionstateEnlist

 internal void TransactionstateEnlist(EnlistmentTraceIdentifier enlistmentID, EnlistmentType enlistmentType, EnlistmentOptions enlistmentOption)
 {
     if (IsEnabled(EventLevel.Informational, ALL_KEYWORDS))
     {
         TransactionstateEnlist(enlistmentID.EnlistmentIdentifier.ToString(), enlistmentType.ToString(), enlistmentOption.ToString());
     }
 }
开发者ID:chcosta,项目名称:corefx,代码行数:7,代码来源:TransactionsEtwProvider.cs

示例3: TestCase_VolatileEnlistments

        private static void TestCase_VolatileEnlistments(
            int count,
            TransactionStatus expectedOutcome,
            EnlistmentOptions options = EnlistmentOptions.None,
            bool commitTx = true,
            bool votePrepared = true,
            Type expectedExceptionType = null)
        {
            string testCaseDescription = string.Format("TestCase_VolatileEnlistments; count = {0}; expectedOutcome = {1}; options = {2}; votePrepared = {3}, expectedExceptionType = {4}",
                        count,
                        expectedOutcome.ToString(),
                        options.ToString(),
                        votePrepared,
                        expectedExceptionType);

            Trace("**** " + testCaseDescription + " ****");

            AutoResetEvent[] enlistmentDoneEvts = new AutoResetEvent[count];
            MyEnlistment[] vols = new MyEnlistment[count];
            for (int i = 0; i < count; i++)
            {
                enlistmentDoneEvts[i] = new AutoResetEvent(false);
            }

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    for (int i = 0; i < count; i++)
                    {
                        vols[i] = CreateVolatileEnlistment(enlistmentDoneEvts[i], null, options, votePrepared);
                    }
                    if (commitTx)
                    {
                        ts.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.GetType() != expectedExceptionType)
                {
                    TestFailed(testCaseDescription, string.Format("Unexpected exception {0}: {1}", ex.GetType().ToString(), ex.ToString()));
                    return;
                }
            }

            for (int i = 0; i < count; i++)
            {
                if (!enlistmentDoneEvts[i].WaitOne(TimeSpan.FromSeconds(5)))
                {
                    TestFailed(testCaseDescription, "Timeout waiting for enlistment outcomes");
                    return;
                }
            }

            int passCount = 0;
            for (int i = 0; i < count; i++)
            {
                if (((expectedOutcome == TransactionStatus.Committed) && vols[i].CommittedOutcome) ||
                    ((expectedOutcome == TransactionStatus.Aborted) && vols[i].AbortedOutcome) ||
                    ((expectedOutcome == TransactionStatus.InDoubt) && vols[i].InDoubtOutcome)
                    )
                {
                    passCount++;
                }
            }
            if (passCount == count)
            {
                TestPassed();
            }
            else
            {
                TestFailed(testCaseDescription, string.Format("{0} enlistments received an outcome of {1}", passCount, expectedOutcome.ToString()));
            }
        }
开发者ID:Corillian,项目名称:corefx,代码行数:76,代码来源:NonMsdtcPromoterTests.cs

示例4: TestCase_EnlistDuringPrepare

        public static void TestCase_EnlistDuringPrepare(bool promote,
            bool beforePromote,
            EnlistmentOptions firstOptions = EnlistmentOptions.None,
            EnlistmentOptions secondOptions = EnlistmentOptions.None,
            bool expectSecondEnlistSuccess = true
            )
        {
            string testCaseDescription = string.Format(
                "TestCase_EnlistDuringPrepare promote={0}; beforePromote={1}, firstOptions={2}, secondOptions={3}, expectSecondEnlistSuccess={4}",
                promote,
                beforePromote,
                firstOptions.ToString(),
                secondOptions.ToString(),
                expectSecondEnlistSuccess
                );

            Trace("**** " + testCaseDescription + " ****");

            AutoResetEvent volCompleted = new AutoResetEvent(false);
            AutoResetEvent vol2Completed = new AutoResetEvent(false);
            AutoResetEvent pspeCompleted = new AutoResetEvent(false);
            MyEnlistment vol = null;
            NonMSDTCPromoterEnlistment pspe = null;

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    if (beforePromote)
                    {
                        vol = new MyEnlistment(
                            volCompleted,
                            true,
                            true,
                            secondOptions,
                            /*expectSuccessfulEnlist=*/ expectSecondEnlistSuccess,
                            vol2Completed);
                        vol.TransactionToEnlist = Transaction.Current;
                        Transaction.Current.EnlistVolatile(vol, firstOptions);
                    }

                    pspe = (NonMSDTCPromoterEnlistment)CreatePSPEEnlistment(NonMsdtcPromoterTests.PromoterType1,
                        NonMsdtcPromoterTests.PromotedToken1,
                        pspeCompleted,
                        /*nonMSDTC = */ true,
                        /*tx = */ null,
                        /*spcResponse=*/ TransactionStatus.Committed,
                        /*expectRejection=*/ false
                        );

                    if (promote)
                    {
                        Promote(testCaseDescription, NonMsdtcPromoterTests.PromotedToken1);

                        if (!beforePromote)
                        {
                            vol = new MyEnlistment(
                                volCompleted,
                                true,
                                true,
                                secondOptions,
                                /*expectSuccessfulEnlist=*/ expectSecondEnlistSuccess,
                                vol2Completed);
                            vol.TransactionToEnlist = Transaction.Current;
                            Transaction.Current.EnlistVolatile(vol, firstOptions);
                        }
                    }

                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                TestFailed(testCaseDescription, string.Format("Unexpected exception {0}: {1}", ex.GetType().ToString(), ex.ToString()));
                return;
            }

            if (!expectSecondEnlistSuccess)
            {
                vol2Completed.Set();
            }

            if (!volCompleted.WaitOne(TimeSpan.FromSeconds(5)) || !vol2Completed.WaitOne(TimeSpan.FromSeconds(5)) ||
                !pspeCompleted.WaitOne(TimeSpan.FromSeconds(5)))
            {
                TestFailed(testCaseDescription, "Timeout waiting for enlistment outcomes");
                return;
            }

            //if (WaitHandle.WaitAll(new WaitHandle[3] { volCompleted, vol2Completed, pspeCompleted }, TimeSpan.FromSeconds(5)))
            //{
            if (vol.AbortedOutcome)
            {
                TestFailed(testCaseDescription, "The volatile enlistment aborted unexpectedly");
            }

            if (!promote && pspe.Promoted)
            {
                TestFailed(testCaseDescription, "The enlistment promoted");
                return;
//.........这里部分代码省略.........
开发者ID:Corillian,项目名称:corefx,代码行数:101,代码来源:NonMsdtcPromoterTests.cs

示例5: TestCase_AbortFromVolatile

        public static void TestCase_AbortFromVolatile(bool promote, EnlistmentOptions enlistmentOptions = EnlistmentOptions.None)
        {
            string testCaseDescription = string.Format(
                "TestCase_AbortFromVolatile promote={0}; enlistmentOptions = {1}",
                promote,
                enlistmentOptions.ToString()
                );

            Trace("**** " + testCaseDescription + " ****");

            AutoResetEvent volCompleted = new AutoResetEvent(false);
            AutoResetEvent pspeCompleted = new AutoResetEvent(false);
            MyEnlistment vol = null;
            NonMSDTCPromoterEnlistment pspe = null;

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    vol = CreateVolatileEnlistment(volCompleted, null, enlistmentOptions, false);

                    pspe = (NonMSDTCPromoterEnlistment)CreatePSPEEnlistment(NonMsdtcPromoterTests.PromoterType1,
                        NonMsdtcPromoterTests.PromotedToken1,
                        pspeCompleted,
                        /*nonMSDTC = */ true,
                        /*tx = */ null,
                        /*spcResponse=*/ TransactionStatus.Committed,
                        /*expectRejection=*/ false
                        );

                    if (promote)
                    {
                        Promote(testCaseDescription, NonMsdtcPromoterTests.PromotedToken1);
                    }

                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                if (ex.GetType() != typeof(TransactionAbortedException))
                {
                    TestFailed(testCaseDescription, string.Format("Unexpected exception {0}: {1}", ex.GetType().ToString(), ex.ToString()));
                    return;
                }
            }

            if (!volCompleted.WaitOne(TimeSpan.FromSeconds(5)) || !pspeCompleted.WaitOne(TimeSpan.FromSeconds(5)))
            {
                TestFailed(testCaseDescription, "Timeout waiting for enlistment outcomes");
                return;
            }

            //if (WaitHandle.WaitAll(new WaitHandle[2] { volCompleted, pspeCompleted }, TimeSpan.FromSeconds(5)))
            //{
            if (!vol.AbortedOutcome)
            {
                TestFailed(testCaseDescription, "The volatile enlistment did not abort");
            }

            if (!promote && pspe.Promoted)
            {
                TestFailed(testCaseDescription, "The enlistment promoted");
                return;
            }

            if (promote && !pspe.Promoted)
            {
                TestFailed(testCaseDescription, "The enlistment was not promoted");
                return;
            }

            if (!(pspe.Aborted))
            {
                TestFailed(testCaseDescription, "The enlistment did not abort");
                return;
            }

            TestPassed();
            //}
            //else
            //{
            //    TestFailed(testCaseDescription, "Timeout waiting for enlistment outcomes");
            //}
        }
开发者ID:Corillian,项目名称:corefx,代码行数:85,代码来源:NonMsdtcPromoterTests.cs

示例6: TestCase_AbortFromVolatile

        public static void TestCase_AbortFromVolatile(bool promote, EnlistmentOptions enlistmentOptions = EnlistmentOptions.None)
        {
            string testCaseDescription = string.Format(
                "TestCase_AbortFromVolatile promote={0}; enlistmentOptions = {1}",
                promote,
                enlistmentOptions.ToString()
                );

            Trace("**** " + testCaseDescription + " ****");

            AutoResetEvent volCompleted = new AutoResetEvent(false);
            AutoResetEvent pspeCompleted = new AutoResetEvent(false);
            MyEnlistment vol = null;
            NonMSDTCPromoterEnlistment pspe = null;

            Assert.Throws<TransactionAbortedException>(() =>
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    vol = CreateVolatileEnlistment(volCompleted, null, enlistmentOptions, false);

                    pspe = (NonMSDTCPromoterEnlistment)CreatePSPEEnlistment(NonMsdtcPromoterTests.PromoterType1,
                        NonMsdtcPromoterTests.PromotedToken1,
                        pspeCompleted,
                        /*nonMSDTC = */ true,
                        /*tx = */ null,
                        /*spcResponse=*/ TransactionStatus.Committed,
                        /*expectRejection=*/ false
                        );

                    if (promote)
                    {
                        Promote(testCaseDescription, NonMsdtcPromoterTests.PromotedToken1);
                    }

                    ts.Complete();
                }
            });

            Assert.True(volCompleted.WaitOne(TimeSpan.FromSeconds(5)) && pspeCompleted.WaitOne(TimeSpan.FromSeconds(5)));

            Assert.True(vol.AbortedOutcome);

            if (promote)
            {
                Assert.True(pspe.Promoted);
            }
            else
            {
                Assert.False(pspe.Promoted);
            }

            Assert.True(pspe.Aborted);

            TestPassed();
        }
开发者ID:dotnet,项目名称:corefx,代码行数:56,代码来源:NonMsdtcPromoterTests.cs

示例7: TestCase_EnlistDuringPrepare

        public static void TestCase_EnlistDuringPrepare(bool promote,
            bool beforePromote,
            EnlistmentOptions firstOptions = EnlistmentOptions.None,
            EnlistmentOptions secondOptions = EnlistmentOptions.None,
            bool expectSecondEnlistSuccess = true
            )
        {
            string testCaseDescription = string.Format(
                "TestCase_EnlistDuringPrepare promote={0}; beforePromote={1}, firstOptions={2}, secondOptions={3}, expectSecondEnlistSuccess={4}",
                promote,
                beforePromote,
                firstOptions.ToString(),
                secondOptions.ToString(),
                expectSecondEnlistSuccess
                );

            Trace("**** " + testCaseDescription + " ****");

            AutoResetEvent volCompleted = new AutoResetEvent(false);
            AutoResetEvent vol2Completed = new AutoResetEvent(false);
            AutoResetEvent pspeCompleted = new AutoResetEvent(false);
            MyEnlistment vol = null;
            NonMSDTCPromoterEnlistment pspe = null;

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    if (beforePromote)
                    {
                        vol = new MyEnlistment(
                            volCompleted,
                            true,
                            true,
                            secondOptions,
                            /*expectSuccessfulEnlist=*/ expectSecondEnlistSuccess,
                            vol2Completed);
                        vol.TransactionToEnlist = Transaction.Current;
                        Transaction.Current.EnlistVolatile(vol, firstOptions);
                    }

                    pspe = (NonMSDTCPromoterEnlistment)CreatePSPEEnlistment(NonMsdtcPromoterTests.PromoterType1,
                        NonMsdtcPromoterTests.PromotedToken1,
                        pspeCompleted,
                        /*nonMSDTC = */ true,
                        /*tx = */ null,
                        /*spcResponse=*/ TransactionStatus.Committed,
                        /*expectRejection=*/ false
                        );

                    if (promote)
                    {
                        Promote(testCaseDescription, NonMsdtcPromoterTests.PromotedToken1);

                        if (!beforePromote)
                        {
                            vol = new MyEnlistment(
                                volCompleted,
                                true,
                                true,
                                secondOptions,
                                /*expectSuccessfulEnlist=*/ expectSecondEnlistSuccess,
                                vol2Completed);
                            vol.TransactionToEnlist = Transaction.Current;
                            Transaction.Current.EnlistVolatile(vol, firstOptions);
                        }
                    }

                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                Assert.Null(ex);
            }

            if (!expectSecondEnlistSuccess)
            {
                vol2Completed.Set();
            }

            Assert.True(volCompleted.WaitOne(TimeSpan.FromSeconds(5)) && vol2Completed.WaitOne(TimeSpan.FromSeconds(5)) &&
                pspeCompleted.WaitOne(TimeSpan.FromSeconds(5)));

            Assert.False(vol.AbortedOutcome);

            if (promote)
            {
                Assert.True(pspe.Promoted);
            }
            else
            {
                Assert.False(pspe.Promoted);
            }

            Assert.False(pspe.Aborted);

            TestPassed();
        }
开发者ID:dotnet,项目名称:corefx,代码行数:99,代码来源:NonMsdtcPromoterTests.cs


注:本文中的EnlistmentOptions.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。