Skip to content

Commit de2d561

Browse files
Implemeted FlowFork activity
1 parent 683f0ee commit de2d561

File tree

1 file changed

+37
-0
lines changed
  • src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Elsa.Extensions;
2+
using Elsa.Workflows.Core.Attributes;
3+
using Elsa.Workflows.Core.Models;
4+
using JetBrains.Annotations;
5+
using System.Runtime.CompilerServices;
6+
7+
namespace Elsa.Workflows.Core.Activities.Flowchart.Activities;
8+
9+
/// <summary>
10+
/// Branch execution into multiple branches that will be executed in parallel.
11+
/// </summary>
12+
[Activity("Elsa", "Branching", "Branch execution into multiple branches that will be executed in parallel.", DisplayName = "Fork (flow)")]
13+
[PublicAPI]
14+
public class FlowFork : Activity
15+
{
16+
/// <inheritdoc />
17+
public FlowFork([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
18+
{
19+
}
20+
21+
/// <summary>
22+
/// A list of expected outcomes to handle.
23+
/// </summary>
24+
[Input(
25+
Description = "A list of expected outcomes to handle.",
26+
UIHint = InputUIHints.DynamicOutcomes
27+
)]
28+
public Input<ICollection<string>> Branches { get; set; } = default!;
29+
30+
/// <inheritdoc />
31+
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
32+
{
33+
var outcomes = Branches.GetOrDefault(context)?.ToArray() ?? new[] { "Done" };
34+
35+
await context.ScheduleOutcomesAsync(outcomes);
36+
}
37+
}

0 commit comments

Comments
 (0)