| | | 1 | | using System.Text.Json.Serialization; |
| | | 2 | | |
| | | 3 | | namespace Elsa.Expressions.Models; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Represents an expression. |
| | | 7 | | /// </summary> |
| | | 8 | | public partial class Expression |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Initializes a new instance of the <see cref="Expression"/> class. |
| | | 12 | | /// </summary> |
| | | 13 | | [JsonConstructor] |
| | 355 | 14 | | public Expression() |
| | | 15 | | { |
| | 355 | 16 | | } |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Initializes a new instance of the <see cref="Expression"/> class. |
| | | 20 | | /// </summary> |
| | | 21 | | /// <param name="type">The expression type.</param> |
| | | 22 | | /// <param name="value">The expression.</param> |
| | 5550 | 23 | | public Expression(string type, object? value) |
| | | 24 | | { |
| | 5550 | 25 | | Type = type; |
| | 5550 | 26 | | Value = value; |
| | 5550 | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Gets or sets the expression type. |
| | | 31 | | /// </summary> |
| | 10529 | 32 | | public string Type { get; set; } = default!; |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Gets or sets the expression. |
| | | 36 | | /// </summary> |
| | 9227 | 37 | | public object? Value { get; set; } |
| | | 38 | | |
| | | 39 | | /// <summary> |
| | | 40 | | /// Creates an expression that represents a literal value. |
| | | 41 | | /// </summary> |
| | | 42 | | /// <param name="value">The literal value.</param> |
| | | 43 | | /// <returns>An expression that represents a literal value.</returns> |
| | 3438 | 44 | | public static Expression LiteralExpression(object? value) => new("Literal", value); |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// Creates an expression that represents a delegate. |
| | | 48 | | /// </summary> |
| | | 49 | | /// <param name="value">The delegate.</param> |
| | | 50 | | /// <returns>An expression that represents a delegate.</returns> |
| | 355 | 51 | | public static Expression DelegateExpression(Func<ExpressionExecutionContext, ValueTask<object?>> value) => new() |
| | 355 | 52 | | { |
| | 355 | 53 | | Type = "Delegate", |
| | 355 | 54 | | Value = value |
| | 355 | 55 | | }; |
| | | 56 | | |
| | | 57 | | /// <summary> |
| | | 58 | | /// Creates an expression that represents a delegate. |
| | | 59 | | /// </summary> |
| | | 60 | | /// <param name="value">The delegate.</param> |
| | | 61 | | /// <typeparam name="T">The return type of the delegate.</typeparam> |
| | | 62 | | /// <returns>An expression that represents a delegate.</returns> |
| | 0 | 63 | | public static Expression DelegateExpression<T>(Func<ExpressionExecutionContext, ValueTask<T>> value) => DelegateExpr |
| | | 64 | | |
| | | 65 | | /// <summary> |
| | | 66 | | /// Creates an expression that represents a delegate. |
| | | 67 | | /// </summary> |
| | | 68 | | /// <param name="value">The delegate.</param> |
| | | 69 | | /// <typeparam name="T">The return type of the delegate.</typeparam> |
| | | 70 | | /// <returns>An expression that represents a delegate.</returns> |
| | 0 | 71 | | public static Expression DelegateExpression<T>(Func<ValueTask<T>> value) => DelegateExpression(_ => ValueTask.FromRe |
| | | 72 | | |
| | | 73 | | /// <summary> |
| | | 74 | | /// Creates an expression that represents a delegate. |
| | | 75 | | /// </summary> |
| | | 76 | | /// <param name="value">The delegate.</param> |
| | | 77 | | /// <typeparam name="T">The return type of the delegate.</typeparam> |
| | | 78 | | /// <returns>An expression that represents a delegate.</returns> |
| | 376 | 79 | | public static Expression DelegateExpression<T>(Func<ExpressionExecutionContext, T> value) => DelegateExpression(cont |
| | | 80 | | |
| | | 81 | | /// <summary> |
| | | 82 | | /// Creates an expression that represents a delegate. |
| | | 83 | | /// </summary> |
| | | 84 | | /// <param name="value">The delegate.</param> |
| | | 85 | | /// <typeparam name="T">The return type of the delegate.</typeparam> |
| | | 86 | | /// <returns>An expression that represents a delegate.</returns> |
| | 19 | 87 | | public static Expression DelegateExpression<T>(Func<T> value) => DelegateExpression(_ => ValueTask.FromResult<object |
| | | 88 | | } |