< Summary

Information
Class: Elsa.Api.Client.Converters.VersionOptionsJsonConverter
Assembly: Elsa.Api.Client
File(s): /home/runner/work/elsa-core/elsa-core/src/clients/Elsa.Api.Client/Converters/VersionOptionsJsonConverter.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 4
Coverable lines: 4
Total lines: 24
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Read(...)0%620%
Write(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/clients/Elsa.Api.Client/Converters/VersionOptionsJsonConverter.cs

#LineLine coverage
 1using System.Text.Json;
 2using System.Text.Json.Serialization;
 3using Elsa.Api.Client.Shared.Models;
 4
 5namespace Elsa.Api.Client.Converters;
 6
 7/// <summary>
 8/// A JSON converter that serializes <see cref="VersionOptions"/>.
 9/// </summary>
 10public class VersionOptionsJsonConverter : JsonConverter<VersionOptions>
 11{
 12    /// <inheritdoc />
 13    public override VersionOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 14    {
 015        var textValue = reader.GetString();
 016        return string.IsNullOrWhiteSpace(textValue) ? VersionOptions.Published : VersionOptions.FromString(textValue);
 17    }
 18
 19    /// <inheritdoc />
 20    public override void Write(Utf8JsonWriter writer, VersionOptions value, JsonSerializerOptions options)
 21    {
 022        writer.WriteStringValue(value.ToString());
 023    }
 24}