Add Object expression to API client

This commit is contained in:
Sipke Schoorstra 2023-06-24 13:13:47 +02:00
parent 4857a12b79
commit be8436730f
2 changed files with 38 additions and 0 deletions

View file

@ -51,6 +51,7 @@ public class ExpressionJsonConverter : JsonConverter<IExpression>
"Literal" => typeof(LiteralExpression),
"JavaScript" => typeof(JavaScriptExpression),
"Liquid" => typeof(LiquidExpression),
"Object" => typeof(ObjectExpression),
_ => throw new ArgumentOutOfRangeException(nameof(expressionTypeName), expressionTypeName, null)
};
@ -60,6 +61,7 @@ public class ExpressionJsonConverter : JsonConverter<IExpression>
nameof(LiteralExpression) => "Literal",
nameof(JavaScriptExpression) => "JavaScript",
nameof(LiquidExpression) => "Liquid",
nameof(ObjectExpression) => "Object",
_ => throw new ArgumentOutOfRangeException(nameof(expressionType), expressionType, null)
};
}

View file

@ -0,0 +1,36 @@
using System.Text.Json.Serialization;
using Elsa.Api.Client.Contracts;
namespace Elsa.Api.Client.Expressions;
/// <summary>
/// Represents an object expression formatted as a string value.
/// </summary>
public class ObjectExpression : IExpression
{
/// <summary>
/// Initializes a new instance of the <see cref="ObjectExpression"/> class.
/// </summary>
[JsonConstructor]
public ObjectExpression()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ObjectExpression"/> class.
/// </summary>
public ObjectExpression(string? value)
{
Value = value;
}
/// <summary>
/// The literal value.
/// </summary>
public string? Value { get; set; }
/// <summary>
/// Returns the string representation of the expression.
/// </summary>
public override string ToString() => Value?.ToString() ?? "";
}