From be8436730f311da0f209e99dfb4ac9d210595050 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sat, 24 Jun 2023 13:13:47 +0200 Subject: [PATCH] Add Object expression to API client --- .../Converters/ExpressionJsonConverter.cs | 2 ++ .../Expressions/ObjectExpression.cs | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/clients/Elsa.Api.Client/Expressions/ObjectExpression.cs diff --git a/src/clients/Elsa.Api.Client/Converters/ExpressionJsonConverter.cs b/src/clients/Elsa.Api.Client/Converters/ExpressionJsonConverter.cs index db5211b60..1248a4d74 100644 --- a/src/clients/Elsa.Api.Client/Converters/ExpressionJsonConverter.cs +++ b/src/clients/Elsa.Api.Client/Converters/ExpressionJsonConverter.cs @@ -51,6 +51,7 @@ public class ExpressionJsonConverter : JsonConverter "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 nameof(LiteralExpression) => "Literal", nameof(JavaScriptExpression) => "JavaScript", nameof(LiquidExpression) => "Liquid", + nameof(ObjectExpression) => "Object", _ => throw new ArgumentOutOfRangeException(nameof(expressionType), expressionType, null) }; } \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Expressions/ObjectExpression.cs b/src/clients/Elsa.Api.Client/Expressions/ObjectExpression.cs new file mode 100644 index 000000000..c508c3595 --- /dev/null +++ b/src/clients/Elsa.Api.Client/Expressions/ObjectExpression.cs @@ -0,0 +1,36 @@ +using System.Text.Json.Serialization; +using Elsa.Api.Client.Contracts; + +namespace Elsa.Api.Client.Expressions; + +/// +/// Represents an object expression formatted as a string value. +/// +public class ObjectExpression : IExpression +{ + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public ObjectExpression() + { + } + + /// + /// Initializes a new instance of the class. + /// + public ObjectExpression(string? value) + { + Value = value; + } + + /// + /// The literal value. + /// + public string? Value { get; set; } + + /// + /// Returns the string representation of the expression. + /// + public override string ToString() => Value?.ToString() ?? ""; +} \ No newline at end of file