You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can define multiple independent branches within your workflow and select one based on an expression value.
6
+
7
+
For the fluent API, we define our branches with the `CreateBranch()` method on the workflow builder. We can then select a branch using the `Decision` step.
8
+
9
+
This workflow will select `branch1` if the value of `data.Value1` is `one`, and `branch2` if it is `two`.
10
+
```c#
11
+
varbranch1=builder.CreateBranch()
12
+
.StartWith<PrintMessage>()
13
+
.Input(step=>step.Message, data=>"hi from 1")
14
+
.Then<PrintMessage>()
15
+
.Input(step=>step.Message, data=>"bye from 1");
16
+
17
+
varbranch2=builder.CreateBranch()
18
+
.StartWith<PrintMessage>()
19
+
.Input(step=>step.Message, data=>"hi from 2")
20
+
.Then<PrintMessage>()
21
+
.Input(step=>step.Message, data=>"bye from 2");
22
+
23
+
24
+
builder
25
+
.StartWith<HelloWorld>()
26
+
.Decide(data=>data.Value1)
27
+
.Branch("one", branch1)
28
+
.Branch("two", branch2);
29
+
```
30
+
31
+
The JSON representation would look somthing like this.
Copy file name to clipboardExpand all lines: docs/json-yaml.md
+66Lines changed: 66 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -480,3 +480,69 @@ Do:
480
480
- Id: do2
481
481
StepType: MyApp.DoSomething2, MyApp
482
482
```
483
+
484
+
### Decision Branches
485
+
486
+
You can define multiple independent branches within your workflow and select one based on an expression value.
487
+
Use the `Decide` primitive step and hook up your branches via the `OutcomeSteps` property. The result of the input expression will be matched to the expressions listed in `OutcomeSteps`, and the matching next step(s) will be scheduled to execute next.
0 commit comments