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