< Summary

Information
Class: Elsa.Expressions.Models.ObjectLiteral
Assembly: Elsa.Expressions
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions/Models/ObjectLiteral.cs
Line coverage
71%
Covered lines: 5
Uncovered lines: 2
Coverable lines: 7
Total lines: 48
Line coverage: 71.4%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
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%11100%
get_Value()100%11100%
From(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions/Models/ObjectLiteral.cs

#LineLine coverage
 1using System.Text.Json;
 2using System.Text.Json.Serialization;
 3
 4namespace Elsa.Expressions.Models;
 5
 6/// <summary>
 7/// Represents a literal JSON expression.
 8/// </summary>
 9public class ObjectLiteral : MemoryBlockReference
 10{
 11    /// <inheritdoc />
 12    [JsonConstructor]
 013    public ObjectLiteral()
 14    {
 015    }
 16
 17    /// <inheritdoc />
 33318    public ObjectLiteral(string? value)
 19    {
 33320        Value = value;
 33321    }
 22
 23    /// <summary>
 24    /// The literal JSON string value.
 25    /// </summary>
 33326    public string? Value { get; }
 27
 28    /// <summary>
 29    /// Serializes the value into a JSON string in the form of a <see cref="ObjectLiteral{T}"/>
 30    /// </summary>
 33331    public static ObjectLiteral From<T>(T value) => new ObjectLiteral<T>(value);
 32}
 33
 34/// <summary>
 35/// Represents a JSON string for the specified type <code>T</code>
 36/// </summary>
 37public class ObjectLiteral<T> : ObjectLiteral
 38{
 39    /// <inheritdoc />
 40    public ObjectLiteral()
 41    {
 42    }
 43
 44    /// <inheritdoc />
 45    public ObjectLiteral(T value) : base(JsonSerializer.Serialize(value!))
 46    {
 47    }
 48}