forked from elsa-workflows/elsa-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BreakWhileForkWorkflow.cs
52 lines (49 loc) · 1.73 KB
/
BreakWhileForkWorkflow.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
44
45
46
47
48
49
50
51
52
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
using Elsa.Workflows.Runtime.Activities;
namespace Elsa.IntegrationTests.Activities;
public class BreakWhileForkWorkflow : WorkflowBase
{
protected override void Build(IWorkflowBuilder workflow)
{
var currentValue = new Variable<int?>("CurrentValue", 0);
workflow.Root = new Sequence
{
Variables = { currentValue },
Activities =
{
While.True(new Fork
{
Branches =
{
new Sequence
{
Activities =
{
new SetVariable
{
Variable = currentValue,
Value = new Input<object?>(context => currentValue.Get(context) + 1)
},
new If(context => currentValue.Get(context) == 3)
{
Then = new Break()
}
}
},
new Sequence
{
Activities =
{
new WriteLine("Waiting for event..."),
new Event("Some event") { Id = "SomeEvent" },
new WriteLine("Resuming"),
}
}
}
}),
}
};
}
}