TransactionFlowAttribute 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
서비스 작업이 클라이언트에서 들어오는 트랜잭션을 허용하는지 여부를 지정합니다.
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
- 상속
- 특성
- 구현
예제
다음 코드 예제에서는 작업 수준에서 클래스와 함께 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) |