| | | 1 | | using System.Text.Json.Serialization; |
| | | 2 | | |
| | | 3 | | namespace Elsa.Api.Client.Resources.Scripting.Models; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Represents a dynamic expression. |
| | | 7 | | /// </summary> |
| | | 8 | | public class Expression |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Initializes a new instance of the <see cref="Expression"/> class. |
| | | 12 | | /// </summary> |
| | | 13 | | [JsonConstructor] |
| | 0 | 14 | | public Expression() |
| | | 15 | | { |
| | 0 | 16 | | } |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Initializes a new instance of the <see cref="Expression"/> class. |
| | | 20 | | /// </summary> |
| | | 21 | | /// <param name="type">The type of the expression.</param> |
| | | 22 | | /// <param name="value">The expression.</param> |
| | 0 | 23 | | public Expression(string type, string? value = null) |
| | | 24 | | { |
| | 0 | 25 | | Type = type; |
| | 0 | 26 | | Value = value; |
| | 0 | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Gets or sets the expression type. |
| | | 31 | | /// </summary> |
| | 0 | 32 | | public string Type { get; set; } = null!; |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Gets or sets the value representing the expression. |
| | | 36 | | /// </summary> |
| | 0 | 37 | | public object? Value { get; set; } |
| | | 38 | | |
| | | 39 | | /// <summary> |
| | | 40 | | /// Returns the C# expression. |
| | | 41 | | /// </summary> |
| | 0 | 42 | | public override string ToString() => Value?.ToString() ?? ""; |
| | | 43 | | |
| | | 44 | | /// <summary> |
| | | 45 | | /// Creates a literal expression. |
| | | 46 | | /// </summary> |
| | 0 | 47 | | public static Expression CreateLiteral(string value) => new("Literal", value); |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Creates an object expression. |
| | | 51 | | /// </summary> |
| | 0 | 52 | | public static Expression CreateObject(string value) => new("Object", value); |
| | | 53 | | } |