< Summary

Information
Class: Elsa.Workflows.Serialization.Converters.ExpressionJsonConverterFactory
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Serialization/Converters/ExpressionJsonConverterFactory.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 29
Line coverage: 100%
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%11100%
CanConvert(...)100%11100%
CreateConverter(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Serialization/Converters/ExpressionJsonConverterFactory.cs

#LineLine coverage
 1using System.Text.Json;
 2using System.Text.Json.Serialization;
 3using Elsa.Expressions.Contracts;
 4using Elsa.Expressions.Models;
 5
 6namespace Elsa.Workflows.Serialization.Converters;
 7
 8/// <summary>
 9/// A JSON converter factory that creates <see cref="ExpressionJsonConverter"/> instances.
 10/// </summary>
 11public class ExpressionJsonConverterFactory : JsonConverterFactory
 12{
 13    private readonly IExpressionDescriptorRegistry _expressionDescriptorRegistry;
 14
 15    /// <inheritdoc />
 495216    public ExpressionJsonConverterFactory(IExpressionDescriptorRegistry expressionDescriptorRegistry)
 17    {
 495218        _expressionDescriptorRegistry = expressionDescriptorRegistry;
 495219    }
 20
 21    /// <inheritdoc />
 24645722    public override bool CanConvert(Type typeToConvert) => typeof(Expression).IsAssignableFrom(typeToConvert);
 23
 24    /// <inheritdoc />
 25    public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
 26    {
 150127        return new ExpressionJsonConverter(_expressionDescriptorRegistry);
 28    }
 29}