| | | 1 | | using System.Text.Json.Serialization; |
| | | 2 | | using Elsa.Expressions.Models; |
| | | 3 | | using Elsa.Workflows.Activities.Flowchart.Activities; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Workflows.Activities.Flowchart.Models; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Represents an individual case of the <see cref="FlowSwitch"/> activity. |
| | | 9 | | /// </summary> |
| | | 10 | | public class FlowSwitchCase |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Initializes a new instance of the <see cref="FlowSwitchCase"/> class. |
| | | 14 | | /// </summary> |
| | | 15 | | [JsonConstructor] |
| | 0 | 16 | | public FlowSwitchCase() |
| | | 17 | | { |
| | 0 | 18 | | } |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Initializes a new instance of the <see cref="FlowSwitchCase"/> class. |
| | | 22 | | /// </summary> |
| | | 23 | | /// <param name="label">The label of the case.</param> |
| | | 24 | | /// <param name="condition">The condition of the case.</param> |
| | 10 | 25 | | public FlowSwitchCase(string label, Expression condition) |
| | | 26 | | { |
| | 10 | 27 | | Label = label; |
| | 10 | 28 | | Condition = condition; |
| | 10 | 29 | | } |
| | | 30 | | |
| | | 31 | | /// <inheritdoc /> |
| | 0 | 32 | | public FlowSwitchCase(string label, Func<ExpressionExecutionContext, ValueTask<bool>> condition) : this(label, Expre |
| | | 33 | | { |
| | 0 | 34 | | } |
| | | 35 | | |
| | | 36 | | /// <inheritdoc /> |
| | 0 | 37 | | public FlowSwitchCase(string label, Func<ValueTask<bool>> condition) : this(label, Expression.DelegateExpression(con |
| | | 38 | | { |
| | 0 | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <inheritdoc /> |
| | 0 | 42 | | public FlowSwitchCase(string label, Func<ExpressionExecutionContext, bool> condition) : this(label, Expression.Deleg |
| | | 43 | | { |
| | 0 | 44 | | } |
| | | 45 | | |
| | | 46 | | /// <inheritdoc /> |
| | 8 | 47 | | public FlowSwitchCase(string label, Func<bool> condition) : this(label, Expression.DelegateExpression(condition)) |
| | | 48 | | { |
| | 8 | 49 | | } |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// Gets or sets the label of the case. |
| | | 53 | | /// </summary> |
| | 22 | 54 | | public string Label { get; set; } = null!; |
| | | 55 | | |
| | | 56 | | /// <summary> |
| | | 57 | | /// Gets or sets the condition of the case. |
| | | 58 | | /// </summary> |
| | 38 | 59 | | public Expression Condition { get; set; } = Expression.LiteralExpression(false); |
| | | 60 | | } |