| | | 1 | | using System.Text.Json.Serialization; |
| | | 2 | | using Elsa.Expressions.Models; |
| | | 3 | | using Elsa.Workflows.Memory; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Workflows.Models; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// A base type for the <see cref="Input{T}"/> type. |
| | | 9 | | /// </summary> |
| | | 10 | | public abstract class Input : Argument |
| | | 11 | | { |
| | | 12 | | /// <inheritdoc /> |
| | 0 | 13 | | protected Input(MemoryBlockReference memoryBlockReference, Type type) : base(memoryBlockReference) |
| | | 14 | | { |
| | 0 | 15 | | Type = type; |
| | 0 | 16 | | } |
| | | 17 | | |
| | | 18 | | /// <inheritdoc /> |
| | 8268 | 19 | | protected Input(Expression? expression, MemoryBlockReference memoryBlockReference, Type type) : base(memoryBlockRefe |
| | | 20 | | { |
| | 8268 | 21 | | Expression = expression; |
| | 8268 | 22 | | Type = type; |
| | 8268 | 23 | | } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Gets or sets the expression. |
| | | 27 | | /// </summary> |
| | 7074 | 28 | | public Expression? Expression { get; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Gets the type of the input. |
| | | 32 | | /// </summary> |
| | | 33 | | [JsonPropertyName("typeName")] |
| | 12831 | 34 | | public Type Type { get; set; } |
| | | 35 | | } |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Represents activity input that is evaluated at runtime. |
| | | 39 | | /// </summary> |
| | | 40 | | public class Input<T> : Input |
| | | 41 | | { |
| | | 42 | | /// <inheritdoc /> |
| | | 43 | | public Input(MemoryBlockReference memoryBlockReference) : base(memoryBlockReference, typeof(T)) |
| | | 44 | | { |
| | | 45 | | } |
| | | 46 | | |
| | | 47 | | /// <inheritdoc /> |
| | | 48 | | public Input(T literal, string? id = null) : this(new Literal<T>(literal, id)) |
| | | 49 | | { |
| | | 50 | | } |
| | | 51 | | |
| | | 52 | | /// <inheritdoc /> |
| | | 53 | | public Input(Func<T> @delegate, string? id = null) : this(Expression.DelegateExpression(@delegate), new(id!)) |
| | | 54 | | { |
| | | 55 | | } |
| | | 56 | | |
| | | 57 | | /// <inheritdoc /> |
| | | 58 | | public Input(Func<ExpressionExecutionContext, ValueTask<T?>> @delegate, string? id = null) : this(Expression.Delegat |
| | | 59 | | { |
| | | 60 | | } |
| | | 61 | | |
| | | 62 | | /// <inheritdoc /> |
| | | 63 | | public Input(Func<ValueTask<T?>> @delegate, string? id = null) : this(Expression.DelegateExpression(@delegate), new( |
| | | 64 | | { |
| | | 65 | | } |
| | | 66 | | |
| | | 67 | | /// <inheritdoc /> |
| | | 68 | | public Input(Func<ExpressionExecutionContext, T> @delegate, string? id = null) : this(Expression.DelegateExpression( |
| | | 69 | | { |
| | | 70 | | } |
| | | 71 | | |
| | | 72 | | /// <inheritdoc /> |
| | | 73 | | public Input(Variable variable) : base(new("Variable", variable), variable, typeof(T)) |
| | | 74 | | { |
| | | 75 | | } |
| | | 76 | | |
| | | 77 | | /// <inheritdoc /> |
| | | 78 | | public Input(Output output) : base(new("Output", output), output.MemoryBlockReference(), typeof(T)) |
| | | 79 | | { |
| | | 80 | | } |
| | | 81 | | |
| | | 82 | | /// <inheritdoc /> |
| | | 83 | | public Input(Literal<T> literal) : base(Expression.LiteralExpression(literal.Value), literal, typeof(T)) |
| | | 84 | | { |
| | | 85 | | } |
| | | 86 | | |
| | | 87 | | /// <inheritdoc /> |
| | | 88 | | public Input(Literal literal) : base(Expression.LiteralExpression(literal.Value), literal, typeof(T)) |
| | | 89 | | { |
| | | 90 | | } |
| | | 91 | | |
| | | 92 | | /// <inheritdoc /> |
| | | 93 | | public Input(ObjectLiteral<T> literal) : base(Expression.LiteralExpression(literal.Value), literal, typeof(T)) |
| | | 94 | | { |
| | | 95 | | } |
| | | 96 | | |
| | | 97 | | /// <inheritdoc /> |
| | | 98 | | public Input(ObjectLiteral literal) : base(Expression.LiteralExpression(literal.Value), literal, typeof(T)) |
| | | 99 | | { |
| | | 100 | | } |
| | | 101 | | |
| | | 102 | | /// <inheritdoc /> |
| | | 103 | | public Input(Expression expression, MemoryBlockReference memoryBlockReference) : base(expression, memoryBlockReferen |
| | | 104 | | { |
| | | 105 | | } |
| | | 106 | | |
| | | 107 | | /// <inheritdoc /> |
| | | 108 | | public Input(Expression expression) : this(expression, new()) |
| | | 109 | | { |
| | | 110 | | } |
| | | 111 | | } |