Skip to content

Commit a2ee295

Browse files
committed
fix(sample): Fix WebApiSample InvalidCastException when casting JObject to string
1 parent cf002b8 commit a2ee295

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/samples/WebApiSample/WebApiSample/Workflows/TestWorkflow.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading.Tasks;
5+
using Newtonsoft.Json.Linq;
56
using WorkflowCore.Interface;
67
using WorkflowCore.Models;
78

@@ -18,7 +19,15 @@ public void Build(IWorkflowBuilder<MyDataClass> builder)
1819
builder
1920
.StartWith(context => ExecutionResult.Next())
2021
.WaitFor("MyEvent", (data, context) => context.Workflow.Id, data => DateTime.Now)
21-
.Output(data => data.Value1, step => step.EventData)
22+
.Output((data, step) =>
23+
{
24+
var jsonData = data.EventData as JObject;
25+
if (jsonData != null)
26+
{
27+
var value = jsonData.ToObject<MyDataClass>();
28+
step.Value1 = value?.Value1;
29+
}
30+
})
2231
.Then(context => Console.WriteLine("workflow complete"));
2332
}
2433
}

0 commit comments

Comments
 (0)