forked from elsa-workflows/elsa-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NestedForEachWithBreakWorkflow.cs
43 lines (40 loc) · 1.46 KB
/
NestedForEachWithBreakWorkflow.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
namespace Elsa.IntegrationTests.Activities;
class NestedForEachWithBreakWorkflow : WorkflowBase
{
protected override void Build(IWorkflowBuilder workflow)
{
var outerItems = new[] { "C#", "Rust", "Go" };
var innerItems = new[] { "Classes", "Functions", "Modules" };
var currentOuterItem = new Variable<string>();
var currentInnerItem = new Variable<string>();
workflow.Root = new ForEach<string>(outerItems)
{
CurrentValue = new Output<string?>(currentOuterItem),
Body = new Sequence
{
Activities =
{
new WriteLine(currentOuterItem),
new ForEach<string>(innerItems)
{
CurrentValue = new Output<string?>(currentInnerItem),
Body = new Sequence
{
Activities =
{
new If(context => currentInnerItem.Get(context) == "Functions")
{
Then = new Break()
},
new WriteLine(currentInnerItem)
}
}
}
}
}
};
}
}