本文整理汇总了C#中System.Transactions.InternalTransaction.ThrowIfPromoterTypeIsNotMSDTC方法的典型用法代码示例。如果您正苦于以下问题:C# InternalTransaction.ThrowIfPromoterTypeIsNotMSDTC方法的具体用法?C# InternalTransaction.ThrowIfPromoterTypeIsNotMSDTC怎么用?C# InternalTransaction.ThrowIfPromoterTypeIsNotMSDTC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Transactions.InternalTransaction
的用法示例。
在下文中一共展示了InternalTransaction.ThrowIfPromoterTypeIsNotMSDTC方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetObjectData
internal override void GetObjectData(InternalTransaction tx, SerializationInfo serializationInfo, StreamingContext context)
{
Debug.Assert(tx.PromotedTransaction != null, "Promoted state not valid for transaction.");
// This is not allowed if the transaction's PromoterType is not MSDTC.
tx.ThrowIfPromoterTypeIsNotMSDTC();
// Simply get call get object data for the promoted transaction.
ISerializable serializableTx = tx.PromotedTransaction as ISerializable;
if (serializableTx == null)
{
// The LTM can only support this if the Distributed TM Supports it.
throw new NotSupportedException();
}
// Before forwarding this call to the promoted tx make sure to change
// the full type info so that only if the promoted tx does not set this
// then it should be set correctly.
serializationInfo.FullTypeName = tx.PromotedTransaction.GetType().FullName;
// Now forward the call.
serializableTx.GetObjectData(serializationInfo, context);
}
示例2: EnlistDurable
internal override Enlistment EnlistDurable(
InternalTransaction tx,
Guid resourceManagerIdentifier,
ISinglePhaseNotification enlistmentNotification,
EnlistmentOptions enlistmentOptions,
Transaction atomicTransaction
)
{
Debug.Assert(tx.PromotedTransaction != null, "Promoted state not valid for transaction.");
tx.ThrowIfPromoterTypeIsNotMSDTC();
// Don't hold locks while calling into the promoted tx
Monitor.Exit(tx);
try
{
Enlistment en = new Enlistment(
resourceManagerIdentifier,
tx,
enlistmentNotification,
enlistmentNotification,
atomicTransaction
);
EnlistmentState.EnlistmentStatePromoted.EnterState(en.InternalEnlistment);
en.InternalEnlistment.PromotedEnlistment =
tx.PromotedTransaction.EnlistDurable(
resourceManagerIdentifier,
(DurableInternalEnlistment)en.InternalEnlistment,
true,
enlistmentOptions
);
return en;
}
finally
{
Monitor.Enter(tx);
}
}