Skip to content

(Bug) Updated definition loader to evaluate children inputs #1122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/WorkflowCore.DSL/Services/DefinitionLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,30 @@ void acn(IStepBody pStep, object pData, IStepExecutionContext pContext)
}
}

foreach (var child in subobj.Children<JObject>())
stack.Push(child);
foreach (var child in subobj.Children())
{
var childObject = destObj.SelectToken(child.Path);

if (childObject is JObject)
{
stack.Push(childObject as JObject);
}
else if (childObject is JArray)
{
foreach (var item in childObject as JArray)
{
var elem = destObj.SelectToken(item.Path);
if (elem is JObject)
{
stack.Push(elem as JObject);
}
}
}
}
}

stepProperty.SetValue(pStep, destObj);
}
}
return acn;
}

Expand Down
16 changes: 16 additions & 0 deletions test/WorkflowCore.TestAssets/Steps/DynamicDataStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json.Linq;
using WorkflowCore.Interface;
using WorkflowCore.Models;

namespace WorkflowCore.TestAssets.Steps
{
public class DynamicDataStep : StepBody
{
public JObject DynamicData { get; set; }

public override ExecutionResult Run(IStepExecutionContext context)
{
return ExecutionResult.Next();
}
}
}
18 changes: 18 additions & 0 deletions test/WorkflowCore.TestAssets/stored-dynamic-definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,26 @@
{
"Id": "Step4",
"StepType": "WorkflowCore.TestAssets.Steps.Counter, WorkflowCore.TestAssets",
"NextStepId": "Step5",
"Inputs": { "Value": "data[\"Counter6\"]" },
"Outputs": { "Counter6": "step.Value" }
},
{
"Id": "Step5",
"StepType": "WorkflowCore.TestAssets.Steps.DynamicDataStep, WorkflowCore.TestAssets",
"Inputs": {
"DynamicData": {
"ComplexObject": {
"@Integer": "data[\"Counter1\"]",
"Array": [
{
"@Computed": "data[\"Counter6\"]"
},
"string"
]
}
}
}
}
]
}