我正在使用命令式代码编写自定义活动。在我的组合中,我将接收活动作为组合活动之一。在该活动中,我想动态设置 ServiceContractName 和 OperationName 属性,这意味着,当使用我的自定义活动的开发人员必须设置时。因此,我为此目的声明了一个属性和一个 InArgument。我将此属性和参数值分配给本地(序列变量)。当我尝试将这些变量分配给接收活动属性时,我收到编译时错误。如何将变量分配给接收活动的字符串和 XName 属性。
return new Sequence
{
Variables = { operationName, serviceContractName},
Activities =
{
new Assign<string>
{
To = new OutArgument<string>(serviceContractName),
Value = new InArgument<string>(ctx => ServiceContractName.Get(ctx))
},
new Assign<string>
{
To = new OutArgument<string>(operationName),
Value = new InArgument<string>(ctx => OperationName)
},
new Receive
{
ServiceContractName = serviceContractName,
OperationName = operationName,
CanCreateInstance = true,
Content = new ReceiveMessageContent
{
Message = new OutArgument<Request>(request)
}
}
},
}
};