ContextUtil Klasse

Definition

Ruft Informationen zum COM+-Objektkontext ab. Diese Klasse kann nicht vererbt werden.

public ref class ContextUtil sealed
public sealed class ContextUtil
type ContextUtil = class
Public NotInheritable Class ContextUtil
Vererbung
ContextUtil

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie sie zum Erstellen einer Transaktion ServicedComponentverwendet ContextUtil werden.


[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

Hinweise

ContextUtil ist die bevorzugte Klasse zum Abrufen von COM+-Kontextinformationen. Da die Member dieser Klasse alle static (shared in Visual Basic) sind, ist es nicht erforderlich, sie vor der Verwendung zu instanziieren.

Eigenschaften

Name Beschreibung
ActivityId

Ruft eine GUID, die die Aktivität darstellt, die die Komponente enthält.

ApplicationId

Ruft eine GUID für die aktuelle Anwendung ab.

ApplicationInstanceId

Ruft eine GUID für die aktuelle Anwendungsinstanz ab.

ContextId

Ruft eine GUID für den aktuellen Kontext ab.

DeactivateOnReturn

Ruft das done Bit im COM+-Kontext ab oder legt es fest.

IsInTransaction

Ruft einen Wert ab, der angibt, ob der aktuelle Kontext transaktionsal ist.

IsSecurityEnabled

Ruft einen Wert ab, der angibt, ob die rollenbasierte Sicherheit im aktuellen Kontext aktiv ist.

MyTransactionVote

Ruft das consistent Bit im COM+-Kontext ab oder legt es fest.

PartitionId

Ruft eine GUID für die aktuelle Partition ab.

SystemTransaction

Ruft den aktuellen Transaktionskontext ab.

Transaction

Ruft ein Objekt ab, das die aktuelle COM+DTC-Transaktion beschreibt.

TransactionId

Ruft die GUID der aktuellen COM+DTC-Transaktion ab.

Methoden

Name Beschreibung
DisableCommit()

Legt sowohl das consistent Bit als auch das done Bit false im COM+-Kontext fest.

EnableCommit()

Legt das consistent Bit auf true und das done Bit false im COM+-Kontext fest.

Equals(Object)

Bestimmt, ob das angegebene Objekt gleich dem aktuellen Objekt ist.

(Geerbt von Object)
GetHashCode()

Dient als Standardhashfunktion.

(Geerbt von Object)
GetNamedProperty(String)

Gibt eine benannte Eigenschaft aus dem COM+-Kontext zurück.

GetType()

Ruft die Type der aktuellen Instanz ab.

(Geerbt von Object)
IsCallerInRole(String)

Bestimmt, ob sich der Aufrufer in der angegebenen Rolle befindet.

IsDefaultContext()

Bestimmt, ob die dienstgesteuerte Komponente im Standardkontext aktiviert wird. Dienstierte Komponenten, die nicht über COM+-Kataloginformationen verfügen, werden im Standardkontext aktiviert.

MemberwiseClone()

Erstellt eine flache Kopie der aktuellen Object.

(Geerbt von Object)
SetAbort()

Legt das consistent Bit auf false und das done Bit true im COM+-Kontext fest.

SetComplete()

Legt das consistent Bit und das done Bit true im COM+-Kontext fest.

SetNamedProperty(String, Object)

Legt die benannte Eigenschaft für den COM+-Kontext fest.

ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.

(Geerbt von Object)

Gilt für: