-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
683f0ee
commit de2d561
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/FlowFork.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Elsa.Extensions; | ||
using Elsa.Workflows.Core.Attributes; | ||
using Elsa.Workflows.Core.Models; | ||
using JetBrains.Annotations; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Elsa.Workflows.Core.Activities.Flowchart.Activities; | ||
|
||
/// <summary> | ||
/// Branch execution into multiple branches that will be executed in parallel. | ||
/// </summary> | ||
[Activity("Elsa", "Branching", "Branch execution into multiple branches that will be executed in parallel.", DisplayName = "Fork (flow)")] | ||
[PublicAPI] | ||
public class FlowFork : Activity | ||
{ | ||
/// <inheritdoc /> | ||
public FlowFork([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// A list of expected outcomes to handle. | ||
/// </summary> | ||
[Input( | ||
Description = "A list of expected outcomes to handle.", | ||
UIHint = InputUIHints.DynamicOutcomes | ||
)] | ||
public Input<ICollection<string>> Branches { get; set; } = default!; | ||
|
||
/// <inheritdoc /> | ||
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) | ||
{ | ||
var outcomes = Branches.GetOrDefault(context)?.ToArray() ?? new[] { "Done" }; | ||
|
||
await context.ScheduleOutcomesAsync(outcomes); | ||
} | ||
} |