本文整理汇总了C#中EnlistmentOptions类的典型用法代码示例。如果您正苦于以下问题:C# EnlistmentOptions类的具体用法?C# EnlistmentOptions怎么用?C# EnlistmentOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnlistmentOptions类属于命名空间,在下文中一共展示了EnlistmentOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
示例3: TestCleanup
public void TestCleanup()
{
target = null;
ensureTransaction = true;
options = EnlistmentOptions.None;
enlistmentNotification = null;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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());
}
}
示例13: EnlistDurable
public Enlistment EnlistDurable (Guid manager,
IEnlistmentNotification notification,
EnlistmentOptions options)
{
throw new NotImplementedException ("DTC unsupported, only SinglePhase commit supported for durable resource managers.");
}
示例14: EnlistVolatile
public Enlistment EnlistVolatile(IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions)
{
}
示例15: EnlistDurable
public Enlistment EnlistDurable(System.Guid resourceManagerIdentifier, ISinglePhaseNotification singlePhaseNotification, EnlistmentOptions enlistmentOptions)
{
}