< Summary

Information
Class: Elsa.Workflows.Serialization.Converters.OutputJsonConverterFactory
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Serialization/Converters/OutputJsonConverterFactory.cs
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 27
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
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%22100%

File(s)

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

#LineLine coverage
 1using System.Text.Json;
 2using System.Text.Json.Serialization;
 3using Elsa.Workflows.Models;
 4using Microsoft.Extensions.DependencyInjection;
 5
 6namespace Elsa.Workflows.Serialization.Converters;
 7
 8/// <summary>
 9/// A JSON converter factory that creates <see cref="OutputJsonConverter{T}"/> instances.
 10/// </summary>
 11public class OutputJsonConverterFactory : JsonConverterFactory
 12{
 13    private readonly IServiceProvider _serviceProvider;
 14
 15    /// <inheritdoc />
 880816    public OutputJsonConverterFactory(IServiceProvider serviceProvider) => _serviceProvider = serviceProvider;
 17
 18    /// <inheritdoc />
 24259219    public override bool CanConvert(Type typeToConvert) => typeof(Output).IsAssignableFrom(typeToConvert);
 20
 21    /// <inheritdoc />
 22    public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
 23    {
 152224        var type = typeToConvert.GetGenericArguments().FirstOrDefault() ?? typeof(object);
 152225        return (JsonConverter)ActivatorUtilities.CreateInstance(_serviceProvider, typeof(OutputJsonConverter<>).MakeGene
 26    }
 27}