forked from elsa-workflows/elsa-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BreakForEachWorkflow.cs
40 lines (37 loc) · 1.2 KB
/
BreakForEachWorkflow.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
using System.Collections.Generic;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
namespace Elsa.IntegrationTests.Activities;
class BreakForEachWorkflow : WorkflowBase
{
protected override void Build(IWorkflowBuilder workflow)
{
var items = new[] { "C#", "Rust", "Go" };
var currentItem = new Variable<string>();
workflow.Root = new Sequence
{
Activities =
{
new WriteLine("Start"),
new ForEach<string>
{
Items = new Input<ICollection<string>>(items),
CurrentValue = new Output<string?>(currentItem),
Body = new Sequence
{
Activities =
{
new If(context => currentItem.Get(context) == "Rust")
{
Then = new Break()
},
new WriteLine(currentItem)
}
}
},
new WriteLine("End"),
}
};
}
}