TransactionFlowAttribute クラス

定義

サービス操作がクライアントからの受信トランザクションを受け入れるかどうかを指定します。

public ref class TransactionFlowAttribute sealed : Attribute, System::ServiceModel::Description::IOperationBehavior
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class TransactionFlowAttribute : Attribute, System.ServiceModel.Description.IOperationBehavior
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type TransactionFlowAttribute = class
    inherit Attribute
    interface IOperationBehavior
Public NotInheritable Class TransactionFlowAttribute
Inherits Attribute
Implements IOperationBehavior
継承
TransactionFlowAttribute
属性
実装

次のコード例は、操作レベルでこの列挙体を TransactionFlowOption クラスと共に使用する方法を示しています。

using System;  
using System.ServiceModel;  
using System.Transactions;  

namespace Microsoft.WCF.Documentation  
{  
  [ServiceContract(  
    Namespace="http://microsoft.wcf.documentation",   
    SessionMode=SessionMode.Required  
  )]  
  public interface IBehaviorService  
  {  
    [OperationContract]  
    [TransactionFlow(TransactionFlowOption.Mandatory)]  
    string TxWork(string message);  
  }  

  // Note: To use the TransactionIsolationLevel property, you   
  // must add a reference to the System.Transactions.dll assembly.  
  /* The following service implementation:  
   *   -- Processes messages on one thread at a time  
   *   -- Creates one service object per session  
   *   -- Releases the service object when the transaction commits  
   */  
  [ServiceBehavior(  
    ConcurrencyMode=ConcurrencyMode.Single,  
    InstanceContextMode=InstanceContextMode.PerSession,  
    ReleaseServiceInstanceOnTransactionComplete=true  
  )]  
  public class BehaviorService : IBehaviorService, IDisposable  
  {  
    Guid myID;  

    public BehaviorService()  
    {  
      myID = Guid.NewGuid();  
      Console.WriteLine(  
        "Object "  
        + myID.ToString()  
        + " created.");  
    }  

    /*  
    / * The following operation-level behaviors are specified:  
    / * Always executes under a transaction scope.  
    / * The transaction scope is completed when the operation  
    / * terminates without an unhandled exception.  
    /*  
    [OperationBehavior(  
      TransactionAutoComplete = true,  
      TransactionScopeRequired = true  
    )]  
    public string TxWork(string message)  
    {  
      // Do some transactable work.  
      Console.WriteLine("TxWork called with: " + message);  
      // Display transaction information.  

      TransactionInformation info = Transaction.Current.TransactionInformation;  
      Console.WriteLine("The distributed tx ID: {0}.", info.DistributedIdentifier);  
      Console.WriteLine("The tx status: {0}.", info.Status);  
      return String.Format("Hello. This was object {0}.",myID.ToString()) ;  
    }  

    public void Dispose()  
    {  
      Console.WriteLine(  
        "Service "  
        + myID.ToString()  
        + " is being recycled."  
      );  
    }  
  }  
}  

注釈

TransactionFlowAttributeは、特定のトランザクション フロー ポリシーをサービス操作に関連付けるために宣言によって使用される属性です。 この属性の TransactionFlowOption プロパティは、それぞれの操作がクライアントからフローされたトランザクションを受け入れるか、操作で常にトランザクションをフローさせる必要があるかを指定します。 TransactionFlowAttributeは、トランザクション フロー ポリシーを特定の操作にプログラムで関連付ける操作動作としても使用できます。 この場合は、操作の説明の Behaviors コレクションに追加する必要があります。

Note

OperationContractを使用する各メソッドのTransactionFlowAttributeは、完全修飾Action文字列を提供する必要があります。 値 "*" はサポートされていません。

コンストラクター

名前 説明
TransactionFlowAttribute(TransactionFlowOption)

TransactionFlowAttribute クラスの新しいインスタンスを初期化します。

プロパティ

名前 説明
Transactions

受信トランザクションがサポートされているかどうかを示す値を取得します。

TypeId

派生クラスで実装されている場合は、この Attributeの一意の識別子を取得します。

(継承元 Attribute)

メソッド

名前 説明
Equals(Object)

このインスタンスが指定したオブジェクトと等しいかどうかを示す値を返します。

(継承元 Attribute)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 Attribute)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

派生クラスでオーバーライドされた場合、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)

派生クラスでオーバーライドされた場合、このインスタンスが指定したオブジェクトと等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

名前 説明
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

インターフェイスの型情報を取得するために使用できるオブジェクトの型情報を取得します。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されるプロパティとメソッドへのアクセスを提供します。

(継承元 Attribute)
IOperationBehavior.AddBindingParameters(OperationDescription, BindingParameterCollection)

この操作の動作をサポートするために、バインド コンテキストに追加のパラメーター (設定) を追加します。 このメソッドは継承できません。

IOperationBehavior.ApplyClientBehavior(OperationDescription, ClientOperation)

属性がマークするメソッドの ProxyOperation オブジェクトに属性機能をアタッチします。 このメソッドは継承できません。

IOperationBehavior.ApplyDispatchBehavior(OperationDescription, DispatchOperation)

属性がマークするメソッドの DispatchOperation オブジェクトに属性機能をアタッチします。 このメソッドは継承できません。

IOperationBehavior.Validate(OperationDescription)

操作がこの動作をサポートできることを確認します。 このメソッドは継承できません。

適用対象

こちらもご覧ください