ReceiveActivity.ContextToken 属性

定义

表示一个可用于指定上下文的令牌,应当使用该令牌来关联 ReceiveActivity 活动和该活动与之通信的客户端之间的交换。Represents a token that can be used to specify the context that should be used to correlate the exchange between a ReceiveActivity activity and the client that the activity is communicating with.

public:
 property System::Workflow::Activities::ContextToken ^ ContextToken { System::Workflow::Activities::ContextToken ^ get(); void set(System::Workflow::Activities::ContextToken ^ value); };
[System.ComponentModel.TypeConverter(typeof(System.Workflow.Activities.ContextTokenTypeConverter))]
public System.Workflow.Activities.ContextToken ContextToken { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.Workflow.Activities.ContextTokenTypeConverter))>]
member this.ContextToken : System.Workflow.Activities.ContextToken with get, set
Public Property ContextToken As ContextToken

属性值

ContextToken

可用于关联的 ContextTokenA ContextToken that can be used for correlation.

属性

示例

下面的代码示例演示如何访问 ContextToken 属性。The following code example shows how to access the ContextToken property. 此代码示例根据 Conversations 文件中的 SupplierWorkflow.Designer.cs SDK 示例改写。This code example is adapted from the Conversations SDK sample, from the SupplierWorkflow.Designer.cs file.

ReceiveActivity receiveQuoteFromShipper3;
receiveQuoteFromShipper3 = new System.Workflow.Activities.ReceiveActivity();
System.Workflow.Activities.ContextToken contexttoken1 = new System.Workflow.Activities.ContextToken();
contexttoken1.Name = "Shipper3Context";
receiveQuoteFromShipper3.ContextToken = contexttoken1;

注解

每个 ContextToken 均在所有者活动的范围内定义。Each ContextToken is defined within the scope of an owner activity. 用户可以建立名称相同但所有者范围不同的两个不同的上下文令牌模型。Users can model two distinct context tokens with the same name but different owner scopes. 与这些上下文令牌关联的上下文的值在运行时将有所不同。The value of the contexts associated with these context tokens are different at runtime.

默认情况下,每个工作流都具有一个隐式根上下文令牌,其范围是根活动级别。By default, each workflow has an implicit root context token, scoped at the root activity level. 根上下文令牌的名称为“(RootContext)”,OwnerActivityNamenullThe name of the root context token is '(RootContext)' and the OwnerActivityName is null. 如果 ReceiveActivity 活动没有与其关联的 ContextToken,则将使用根上下文标记。If a ReceiveActivity activity does not have a ContextToken associated with it, the root context token is used.

适用于