WorkflowHostingEndpoint.OnGetInstanceId(Object[], OperationContext) 方法

定义

重写以返回要创建的工作流实例的实例 ID。

protected public:
 virtual Guid OnGetInstanceId(cli::array <System::Object ^> ^ inputs, System::ServiceModel::OperationContext ^ operationContext);
protected internal virtual Guid OnGetInstanceId (object[] inputs, System.ServiceModel.OperationContext operationContext);
abstract member OnGetInstanceId : obj[] * System.ServiceModel.OperationContext -> Guid
override this.OnGetInstanceId : obj[] * System.ServiceModel.OperationContext -> Guid
Protected Friend Overridable Function OnGetInstanceId (inputs As Object(), operationContext As OperationContext) As Guid

参数

inputs
Object[]

对服务操作的输入。

operationContext
OperationContext

服务操作的操作上下文。

返回

新创建的工作流实例的实例 ID。

示例

下面的示例演示如何实现 OnGetInstanceId 方法。

protected override Guid OnGetInstanceId(object[] inputs, OperationContext operationContext)
{
    //Create was called by client
    if (operationContext.IncomingMessageHeaders.Action.EndsWith("Create"))
    {
        return Guid.Empty;
    }
    //CreateWithInstanceId was called by client
    else if (operationContext.IncomingMessageHeaders.Action.EndsWith("CreateWithInstanceId"))
    {
        return (Guid)inputs[1];
    }
    else
    {
        throw new InvalidOperationException("Invalid Action: " + operationContext.IncomingMessageHeaders.Action);
    }
}

注解

返回 null 表明应自动生成实例 ID。

适用于