ContextUtil 類別
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 COM+ 物件內容的資訊。 此類別無法獲得繼承。
public ref class ContextUtil sealed
public sealed class ContextUtil
type ContextUtil = class
Public NotInheritable Class ContextUtil
- 繼承
-
ContextUtil
下列程式代碼範例示範如何使用 ContextUtil 來建立交易 ServicedComponent式 。
[assembly:System::Reflection::AssemblyKeyFile("Transaction.snk")];
[Transaction]
public ref class TransactionalComponent: public ServicedComponent
{
public:
void TransactionalMethod( String^ data )
{
ContextUtil::DeactivateOnReturn = true;
ContextUtil::MyTransactionVote = TransactionVote::Abort;
// do work with data
ContextUtil::MyTransactionVote = TransactionVote::Commit;
}
};
[Transaction]
public class TransactionalComponent : ServicedComponent
{
public void TransactionalMethod (string data)
{
ContextUtil.DeactivateOnReturn = true;
ContextUtil.MyTransactionVote = TransactionVote.Abort;
// Do work with data. Return if any errors occur.
// Vote to commit. If any errors occur, this code will not execute.
ContextUtil.MyTransactionVote = TransactionVote.Commit;
}
}
<Transaction()> _
Public Class TransactionalComponent
Inherits ServicedComponent
Public Sub TransactionalMethod(ByVal data As String)
ContextUtil.DeactivateOnReturn = True
ContextUtil.MyTransactionVote = TransactionVote.Abort
' Do work with data. Return if any errors occur.
' Vote to commit. If any errors occur, this code will not execute.
ContextUtil.MyTransactionVote = TransactionVote.Commit
End Sub
End Class
ContextUtil 是用來取得 COM+ 內容資訊的慣用類別。 由於這個類別的成員全 static
都是在 Visual Basic) 中 (shared
,因此在使用這些成員之前不需要具現化它。
Activity |
取得表示包含元件之活動的 GUID。 |
Application |
取得目前應用程式的 GUID。 |
Application |
取得目前應用程式執行個體的 GUID。 |
Context |
取得目前內容的 GUID。 |
Deactivate |
取得或設定 COM+ 內容中的 |
Is |
取得值,指出目前內容是否可交易。 |
Is |
取得值,指出以角色為基礎的安全性在目前內容中是否為作用中。 |
My |
取得或設定 COM+ 內容中的 |
Partition |
取得目前分割的 GUID。 |
System |
取得目前交易內容。 |
Transaction |
取得描述目前 COM+ DTC 交易的物件。 |
Transaction |
取得目前 COM+ DTC 交易的 GUID。 |
Disable |
在 COM+ 內容中將 |
Enable |
在 COM+ 內容中將 |
Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
Get |
做為預設雜湊函式。 (繼承來源 Object) |
Get |
從 COM+ 內容傳回具名屬性。 |
Get |
取得目前執行個體的 Type。 (繼承來源 Object) |
Is |
判斷呼叫端是否在指定的角色中。 |
Is |
判斷在預設內容中是否啟動 Serviced 元件。 在預設內容中會啟動不具有 COM+ 目錄資訊的 Serviced 元件。 |
Memberwise |
建立目前 Object 的淺層複製。 (繼承來源 Object) |
Set |
在 COM+ 內容中將 |
Set |
在 COM+ 內容中將 |
Set |
設定 COM + 內容的具名屬性。 |
To |
傳回代表目前物件的字串。 (繼承來源 Object) |
產品 | 版本 |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |