Skip to content

Commit

Permalink
Implemeted FlowFork activity
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVuscanNx committed Dec 7, 2023
1 parent 683f0ee commit de2d561
Showing 1 changed file with 37 additions and 0 deletions.
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);
}
}

0 comments on commit de2d561

Please sign in to comment.