< Summary

Information
Class: Elsa.Workflows.Serialization.Converters.InputJsonConverterFactory
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Serialization/Converters/InputJsonConverterFactory.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%22100%
CreateConverter(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Serialization/Converters/InputJsonConverterFactory.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="InputJsonConverter{T}"/> instances.
 10/// </summary>
 11public class InputJsonConverterFactory : JsonConverterFactory
 12{
 13    private readonly IServiceProvider _serviceProvider;
 14
 15    /// <inheritdoc />
 880816    public InputJsonConverterFactory(IServiceProvider serviceProvider) => _serviceProvider = serviceProvider;
 17
 18    /// <inheritdoc />
 24646519    public override bool CanConvert(Type typeToConvert) => typeof(Input).IsAssignableFrom(typeToConvert) && typeToConver
 20
 21    /// <inheritdoc />
 22    public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
 23    {
 387324        var type = typeToConvert.GetGenericArguments().First();
 387325        return (JsonConverter)ActivatorUtilities.CreateInstance(_serviceProvider, typeof(InputJsonConverter<>).MakeGener
 26    }
 27}