共用方式為


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

定義

覆寫以傳回所建立之工作流程執行個體的執行個體識別碼。

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

服務作業的作業內容。

傳回

Guid

新建立之工作流程執行個體的執行個體 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 以表示應自動產生的執行個體識別碼。

適用於