< Summary

Information
Class: Elsa.Api.Client.Resources.Scripting.Models.Expression
Assembly: Elsa.Api.Client
File(s): /home/runner/work/elsa-core/elsa-core/src/clients/Elsa.Api.Client/Resources/Scripting/Models/Expression.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 11
Coverable lines: 11
Total lines: 53
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%210%
.ctor(...)100%210%
get_Type()100%210%
get_Value()100%210%
ToString()0%2040%
CreateLiteral(...)100%210%
CreateObject(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/clients/Elsa.Api.Client/Resources/Scripting/Models/Expression.cs

#LineLine coverage
 1using System.Text.Json.Serialization;
 2
 3namespace Elsa.Api.Client.Resources.Scripting.Models;
 4
 5/// <summary>
 6/// Represents a dynamic expression.
 7/// </summary>
 8public class Expression
 9{
 10    /// <summary>
 11    /// Initializes a new instance of the <see cref="Expression"/> class.
 12    /// </summary>
 13    [JsonConstructor]
 014    public Expression()
 15    {
 016    }
 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>
 023    public Expression(string type, string? value = null)
 24    {
 025        Type = type;
 026        Value = value;
 027    }
 28
 29    /// <summary>
 30    /// Gets or sets the expression type.
 31    /// </summary>
 032    public string Type { get; set; } = null!;
 33
 34    /// <summary>
 35    /// Gets or sets the value representing the expression.
 36    /// </summary>
 037    public object? Value { get; set; }
 38
 39    /// <summary>
 40    /// Returns the C# expression.
 41    /// </summary>
 042    public override string ToString() => Value?.ToString() ?? "";
 43
 44    /// <summary>
 45    /// Creates a literal expression.
 46    /// </summary>
 047    public static Expression CreateLiteral(string value) => new("Literal", value);
 48
 49    /// <summary>
 50    /// Creates an object expression.
 51    /// </summary>
 052    public static Expression CreateObject(string value) => new("Object", value);
 53}