• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# EnlistmentOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TestInitialize

        public void TestInitialize()
        {
            target = new TransactionEnlistmentHelper();

            ensureTransaction = true;
            options = EnlistmentOptions.None;

            enlistmentNotification = MockRepository.GenerateMock<IEnlistmentNotification>();
            enlistmentNotification.Expect( en => en.Prepare( null ) )
                .IgnoreArguments()
                .WhenCalled( a =>
                {
                    PreparingEnlistment e = a.Arguments.GetValue( 0 ) as PreparingEnlistment;
                    e.Prepared();
                } )
                .Repeat.Once();

            enlistmentNotification.Expect( en => en.Commit( null ) )
                .IgnoreArguments()
                .WhenCalled( a =>
                {
                    Enlistment e = a.Arguments.GetValue( 0 ) as Enlistment;
                    e.Done();
                } )
                .Repeat.Once();
        }
开发者ID:RadicalFx,项目名称:Radical,代码行数:26,代码来源:TransactionEnlistmentHelperEventsTest.cs


示例2: EnlistVolatile

		/// <summary>
		/// Enlists a resource manager in this transaction.
		/// </summary>
		/// <param name="p_entNotification">The resource manager to enlist.</param>
		/// <param name="p_eopOptions">The enlistment options. This value must be <see cref="EnlistmentOptions.None"/>.</param>
		/// <exception cref="ArgumentException">Thrown if <paramref name="p_eopOptions"/> is not
		/// <see cref="EnlistmentOptions.None"/>.</exception>
		public void EnlistVolatile(IEnlistmentNotification p_entResourceManager, EnlistmentOptions p_eopOptions)
		{
			if (p_eopOptions != EnlistmentOptions.None)
				throw new ArgumentException("EnlistmentOptions must be None.", "p_eopOptions");

			m_lstNotifications.Add(p_entResourceManager);
		}
开发者ID:NexusMods,项目名称:NexusModManager-4.5,代码行数:14,代码来源:Transaction.cs


示例3: TestCleanup

        public void TestCleanup()
        {
            target = null;
            ensureTransaction = true;
            options = EnlistmentOptions.None;

            enlistmentNotification = null;
        }
开发者ID:RadicalFx,项目名称:Radical,代码行数:8,代码来源:TransactionEnlistmentHelperEventsTest.cs


示例4: OletxVolatileEnlistment

 internal OletxVolatileEnlistment(IEnlistmentNotificationInternal enlistmentNotification, EnlistmentOptions enlistmentOptions, OletxTransaction oletxTransaction) : base(null, oletxTransaction)
 {
     this.iEnlistmentNotification = enlistmentNotification;
     this.enlistDuringPrepareRequired = (enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None;
     this.container = null;
     this.pendingOutcome = TransactionStatus.Active;
     if (DiagnosticTrace.Information)
     {
         EnlistmentTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentType.Volatile, enlistmentOptions);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:OletxVolatileEnlistment.cs


示例5: Enlistment

 internal Enlistment(InternalTransaction transaction, IEnlistmentNotification twoPhaseNotifications, ISinglePhaseNotification singlePhaseNotifications, Transaction atomicTransaction, EnlistmentOptions enlistmentOptions)
 {
     if ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None)
     {
         this.internalEnlistment = new System.Transactions.InternalEnlistment(this, transaction, twoPhaseNotifications, singlePhaseNotifications, atomicTransaction);
     }
     else
     {
         this.internalEnlistment = new Phase1VolatileEnlistment(this, transaction, twoPhaseNotifications, singlePhaseNotifications, atomicTransaction);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:Enlistment.cs


示例6: Trace

 internal static void Trace(string traceSource, EnlistmentTraceIdentifier enTraceId, EnlistmentType enType, EnlistmentOptions enOptions)
 {
     lock (record)
     {
         record.traceSource = traceSource;
         record.enTraceId = enTraceId;
         record.enType = enType;
         record.enOptions = enOptions;
         DiagnosticTrace.TraceEvent(TraceEventType.Information, "http://msdn.microsoft.com/2004/06/System/Transactions/Enlistment", System.Transactions.SR.GetString("TraceEnlistment"), record);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:EnlistmentTraceRecord.cs


示例7: 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


示例8: EnlistDurable

 internal override Enlistment EnlistDurable(InternalTransaction tx, Guid resourceManagerIdentifier, ISinglePhaseNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction)
 {
     if ((tx.durableEnlistment != null) || ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None))
     {
         tx.promoteState.EnterState(tx);
         return tx.State.EnlistDurable(tx, resourceManagerIdentifier, enlistmentNotification, enlistmentOptions, atomicTransaction);
     }
     Enlistment enlistment = new Enlistment(resourceManagerIdentifier, tx, enlistmentNotification, enlistmentNotification, atomicTransaction);
     tx.durableEnlistment = enlistment.InternalEnlistment;
     DurableEnlistmentState._DurableEnlistmentActive.EnterState(tx.durableEnlistment);
     if (DiagnosticTrace.Information)
     {
         EnlistmentTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), tx.durableEnlistment.EnlistmentTraceId, EnlistmentType.Durable, EnlistmentOptions.None);
     }
     return enlistment;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:EnlistableStates.cs


示例9: EnlistVolatile

 internal override Enlistment EnlistVolatile(InternalTransaction tx, ISinglePhaseNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction)
 {
     Enlistment enlistment = new Enlistment(tx, enlistmentNotification, enlistmentNotification, atomicTransaction, enlistmentOptions);
     if ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None)
     {
         base.AddVolatileEnlistment(ref tx.phase0Volatiles, enlistment);
     }
     else
     {
         base.AddVolatileEnlistment(ref tx.phase1Volatiles, enlistment);
     }
     if (DiagnosticTrace.Information)
     {
         EnlistmentTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), enlistment.InternalEnlistment.EnlistmentTraceId, EnlistmentType.Volatile, enlistmentOptions);
     }
     return enlistment;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:TransactionStatePhase0.cs


示例10: TwoPhaseDurable

        public void TwoPhaseDurable(int volatileCount, EnlistmentOptions volatileEnlistmentOption, EnlistmentOptions durableEnlistmentOption, Phase1Vote volatilePhase1Vote, Phase1Vote durablePhase1Vote, bool commit, EnlistmentOutcome expectedVolatileOutcome, EnlistmentOutcome expectedDurableOutcome, TransactionStatus expectedTxStatus)
        {
            Transaction tx = null;
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    tx = Transaction.Current.Clone();

                    if (volatileCount > 0)
                    {
                        TestEnlistment[] volatiles = new TestEnlistment[volatileCount];
                        for (int i = 0; i < volatileCount; i++)
                        {
                            // It doesn't matter what we specify for SinglePhaseVote.
                            volatiles[i] = new TestEnlistment(volatilePhase1Vote, expectedVolatileOutcome);
                            tx.EnlistVolatile(volatiles[i], volatileEnlistmentOption);
                        }
                    }

                    TestEnlistment durable = new TestEnlistment(Phase1Vote.Prepared, expectedDurableOutcome);
                    // TODO: Issue #10353 - This needs to change once we have promotion support.
                    Assert.Throws<PlatformNotSupportedException>(() => // Creation of two phase durable enlistment attempts to promote to MSDTC
                    {
                        tx.EnlistDurable(Guid.NewGuid(), durable, durableEnlistmentOption);
                    });

                    if (commit)
                    {
                        ts.Complete();
                    }
                }
            }
            catch (TransactionInDoubtException)
            {
                Assert.Equal(expectedTxStatus, TransactionStatus.InDoubt);
            }
            catch (TransactionAbortedException)
            {
                Assert.Equal(expectedTxStatus, TransactionStatus.Aborted);
            }

            Assert.NotNull(tx);
            Assert.Equal(expectedTxStatus, tx.TransactionInformation.Status);
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:45,代码来源:LTMEnlistmentTests.cs


示例11: SinglePhaseDurable

        public void SinglePhaseDurable(int volatileCount, EnlistmentOptions volatileEnlistmentOption, Phase1Vote volatilePhase1Vote, SinglePhaseVote singlePhaseVote, bool commit, EnlistmentOutcome expectedVolatileOutcome, TransactionStatus expectedTxStatus)
        {
            Transaction tx = null;
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    tx = Transaction.Current.Clone();

                    if (volatileCount > 0)
                    {
                        TestSinglePhaseEnlistment[] volatiles = new TestSinglePhaseEnlistment[volatileCount];
                        for (int i = 0; i < volatileCount; i++)
                        {
                            // It doesn't matter what we specify for SinglePhaseVote.
                            volatiles[i] = new TestSinglePhaseEnlistment(volatilePhase1Vote, SinglePhaseVote.InDoubt, expectedVolatileOutcome);
                            tx.EnlistVolatile(volatiles[i], volatileEnlistmentOption);
                        }
                    }

                    // Doesn't really matter what we specify for EnlistmentOutcome here. This is an SPC, so Phase2 won't happen for this enlistment.
                    TestSinglePhaseEnlistment durable = new TestSinglePhaseEnlistment(Phase1Vote.Prepared, singlePhaseVote, EnlistmentOutcome.Committed);
                    tx.EnlistDurable(Guid.NewGuid(), durable, EnlistmentOptions.None);

                    if (commit)
                    {
                        ts.Complete();
                    }
                }
            }
            catch (TransactionInDoubtException)
            {
                Assert.Equal(expectedTxStatus, TransactionStatus.InDoubt);
            }
            catch (TransactionAbortedException)
            {
                Assert.Equal(expectedTxStatus, TransactionStatus.Aborted);
            }


            Assert.NotNull(tx);
            Assert.Equal(expectedTxStatus, tx.TransactionInformation.Status);
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:43,代码来源:LTMEnlistmentTests.cs


示例12: 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


示例13: EnlistDurable

		public Enlistment EnlistDurable (Guid manager,
			IEnlistmentNotification notification,
			EnlistmentOptions options)
		{
			throw new NotImplementedException ("DTC unsupported, only SinglePhase commit supported for durable resource managers.");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:6,代码来源:Transaction.cs


示例14: EnlistVolatile

 public Enlistment EnlistVolatile(IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions)
 {
 }
开发者ID:Pengfei-Gao,项目名称:source-Insight-3-for-centos7,代码行数:3,代码来源:SubordinateTransaction.cs


示例15: EnlistDurable

 public Enlistment EnlistDurable(System.Guid resourceManagerIdentifier, ISinglePhaseNotification singlePhaseNotification, EnlistmentOptions enlistmentOptions)
 {
 }
开发者ID:Pengfei-Gao,项目名称:source-Insight-3-for-centos7,代码行数:3,代码来源:SubordinateTransaction.cs


示例16: EnlistVolatile

		public Enlistment EnlistVolatile (
			ISinglePhaseNotification notification,
			EnlistmentOptions options)
		{
			/* FIXME: Anything extra reqd for this? */
			return EnlistVolatileInternal (notification, options);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:7,代码来源:Transaction.cs


示例17: EnlistInTransaction

		/// <summary>
		/// Enlists the supplied transaction manager in the current transaction.
		/// </summary>
		/// <param name="ensureTransaction">if set to <c>true</c> forces an exception if there are no available transactions.</param>
		/// <param name="enlistmentNotification">The <c>IEnlistmentNotification</c> instance to enlist in the transaction.</param>
		/// <param name="options">The transaction enlistment options.</param>
		public void EnlistInTransaction( Boolean ensureTransaction, IEnlistmentNotification enlistmentNotification, EnlistmentOptions options  )
		{
			options.EnsureIsDefined();
			if( enlistmentNotification == null )
			{
				throw new ArgumentNullException( "enlistmentNotification" );
			}

			if( ensureTransaction && Transaction.Current == null )
			{
				throw new InvalidOperationException( "Transaction is mandatory." );
			}

			if( this.EnlistedInTransaction && this.enlistedTransaction != Transaction.Current )
			{
				//Errore siamo in una transazione diversa da quella in cui ci siamo enlisted.
				throw new NotSupportedException( "Multiple Transation detected." );
			}

			if( Transaction.Current != null )
			{
				/*
				 * Dobbiamo inserirci in una Transazione:
				 *	-	ci teniamo un riferimento alla transazione in cui andiamo ad inserirci
				 *	-	chiediamo alla transazione di inserirci all'interno del suo processo
				 */
				this.enlistedTransaction = Transaction.Current;
				this.enlistedTransaction.EnlistVolatile( enlistmentNotification, options );

				/*
				 * Ci interessa tenere traccia di quando la transazione finisce
				 * per liberare un po' di risorse
				 */
				this.enlistedTransaction.TransactionCompleted += new TransactionCompletedEventHandler( OnEnlistedTransactionTransactionCompleted );

				this.OnTransactionEnlisted();
			}
		}
开发者ID:nazarenomanco,项目名称:Radical,代码行数:44,代码来源:TransactionEnlistmentHelper.cs


示例18: CommonEnlistVolatile

 internal IPromotedEnlistment CommonEnlistVolatile(IEnlistmentNotificationInternal enlistmentNotification, EnlistmentOptions enlistmentOptions, OletxTransaction oletxTransaction)
 {
     OletxVolatileEnlistment enlistment = null;
     bool flag2 = false;
     bool flag = false;
     OletxPhase0VolatileEnlistmentContainer target = null;
     OletxPhase1VolatileEnlistmentContainer container = null;
     IntPtr zero = IntPtr.Zero;
     IVoterBallotShim voterBallotShim = null;
     IPhase0EnlistmentShim shim = null;
     bool flag3 = false;
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         lock (this)
         {
             enlistment = new OletxVolatileEnlistment(enlistmentNotification, enlistmentOptions, oletxTransaction);
             if ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None)
             {
                 if (this.phase0EnlistVolatilementContainerList == null)
                 {
                     this.phase0EnlistVolatilementContainerList = new ArrayList(1);
                 }
                 if (this.phase0EnlistVolatilementContainerList.Count == 0)
                 {
                     target = new OletxPhase0VolatileEnlistmentContainer(this);
                     flag = true;
                 }
                 else
                 {
                     target = this.phase0EnlistVolatilementContainerList[this.phase0EnlistVolatilementContainerList.Count - 1] as OletxPhase0VolatileEnlistmentContainer;
                     if (!target.NewEnlistmentsAllowed)
                     {
                         target = new OletxPhase0VolatileEnlistmentContainer(this);
                         flag = true;
                     }
                     else
                     {
                         flag = false;
                     }
                 }
                 if (flag)
                 {
                     zero = HandleTable.AllocHandle(target);
                 }
             }
             else if (this.phase1EnlistVolatilementContainer == null)
             {
                 flag2 = true;
                 container = new OletxPhase1VolatileEnlistmentContainer(this) {
                     voterHandle = HandleTable.AllocHandle(container)
                 };
             }
             else
             {
                 flag2 = false;
                 container = this.phase1EnlistVolatilementContainer;
             }
             try
             {
                 if (flag)
                 {
                     lock (target)
                     {
                         this.transactionShim.Phase0Enlist(zero, out shim);
                         target.Phase0EnlistmentShim = shim;
                     }
                 }
                 if (flag2)
                 {
                     this.transactionShim.CreateVoter(container.voterHandle, out voterBallotShim);
                     flag3 = true;
                     container.VoterBallotShim = voterBallotShim;
                 }
                 if ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None)
                 {
                     target.AddEnlistment(enlistment);
                     if (flag)
                     {
                         this.phase0EnlistVolatilementContainerList.Add(target);
                     }
                     return enlistment;
                 }
                 container.AddEnlistment(enlistment);
                 if (flag2)
                 {
                     this.phase1EnlistVolatilementContainer = container;
                 }
                 return enlistment;
             }
             catch (COMException exception)
             {
                 OletxTransactionManager.ProxyException(exception);
                 throw;
             }
             return enlistment;
         }
     }
     finally
     {
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:RealOletxTransaction.cs


示例19: EnlistVolatile

        // Forward request to the state machine to take the appropriate action.
        //
        /// <include file='doc\Transaction' path='docs/doc[@for="Transaction.EnlistVolatile"]/*' />
        public Enlistment EnlistVolatile(
            ISinglePhaseNotification singlePhaseNotification,
            EnlistmentOptions enlistmentOptions
            )
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                    "Transaction.EnlistVolatile( ISinglePhaseNotification )"
                    );
            }

            if (Disposed)
            {
                throw new ObjectDisposedException("Transaction");
            }

            if (singlePhaseNotification == null)
            {
                throw new ArgumentNullException("singlePhaseNotification");
            }

            if (enlistmentOptions != EnlistmentOptions.None && enlistmentOptions != EnlistmentOptions.EnlistDuringPrepareRequired)
            {
                throw new ArgumentOutOfRangeException("enlistmentOptions");
            }

            if (this.complete)
            {
                throw TransactionException.CreateTransactionCompletedException(SR.GetString(SR.TraceSourceLtm));
            }

            lock (this.internalTransaction)
            {
                Enlistment enlistment = this.internalTransaction.State.EnlistVolatile(this.internalTransaction,
                    singlePhaseNotification, enlistmentOptions, this);

                if (DiagnosticTrace.Verbose)
                {
                    MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                        "Transaction.EnlistVolatile( ISinglePhaseNotification )"
                        );
                }
                return enlistment;
            }
        }
开发者ID:salim18,项目名称:DemoProject2,代码行数:49,代码来源:Transaction.cs


示例20: EnlistDurable

        public Enlistment EnlistDurable(
            Guid resourceManagerIdentifier, 
            IEnlistmentNotification enlistmentNotification,
            EnlistmentOptions enlistmentOptions
            )
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                    "Transaction.EnlistDurable( IEnlistmentNotification )"
                    );
            }

            if (Disposed)
            {
                throw new ObjectDisposedException("Transaction");
            }

            if (resourceManagerIdentifier == Guid.Empty)
            {
                throw new ArgumentException(SR.GetString(SR.BadResourceManagerId), "resourceManagerIdentifier");
            }

            if (enlistmentNotification == null)
            {
                throw new ArgumentNullException("enlistmentNotification");
            }

            if (enlistmentOptions != EnlistmentOptions.None && enlistmentOptions != EnlistmentOptions.EnlistDuringPrepareRequired)
            {
                throw new ArgumentOutOfRangeException("enlistmentOptions");
            }

            if (this.complete)
            {
                throw TransactionException.CreateTransactionCompletedException(SR.GetString(SR.TraceSourceLtm));
            }

            lock (this.internalTransaction)
            {
                Enlistment enlistment = this.internalTransaction.State.EnlistDurable(this.internalTransaction, 
                    resourceManagerIdentifier, enlistmentNotification, enlistmentOptions, this);

                if (DiagnosticTrace.Verbose)
                {
                    MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                        "Transaction.EnlistDurable( IEnlistmentNotification )"
                        );
                }
                return enlistment;
            }
        }
开发者ID:salim18,项目名称:DemoProject2,代码行数:52,代码来源:Transaction.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# EnterRoomParams类代码示例发布时间:2022-05-24
下一篇:
C# EngineWarrior类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap