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 컬렉션에 추가해야 합니다.

메모

OperationContract 이 메서드를 사용하는 각 메서드는 TransactionFlowAttribute 정규화된 Action 문자열을 제공해야 합니다. "*" 값은 지원되지 않습니다.

생성자

Name Description
TransactionFlowAttribute(TransactionFlowOption)

TransactionFlowAttribute 클래스의 새 인스턴스를 초기화합니다.

속성

Name Description
Transactions

들어오는 트랜잭션이 지원되는지 여부를 나타내는 값을 가져옵니다.

TypeId

파생 클래스에서 구현되는 경우 이 Attribute대한 고유 식별자를 가져옵니다.

(다음에서 상속됨 Attribute)

메서드

Name Description
Equals(Object)

이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
GetHashCode()

이 인스턴스의 해시 코드를 반환합니다.

(다음에서 상속됨 Attribute)
GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
IsDefaultAttribute()

파생 클래스에서 재정의되는 경우 이 인스턴스의 값이 파생 클래스의 기본값인지 여부를 나타냅니다.

(다음에서 상속됨 Attribute)
Match(Object)

파생 클래스에서 재정의되는 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

Name Description
_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)

작업이 이 동작을 지원할 수 있음을 확인합니다. 이 메서드는 상속할 수 없습니다.

적용 대상

추가 정보