< Summary

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

#LineLine coverage
 1using System.Text.Json;
 2using System.Text.Json.Serialization;
 3using Microsoft.Extensions.DependencyInjection;
 4
 5namespace Elsa.Workflows.Serialization.Converters;
 6
 7/// <summary>
 8/// Creates instances of <see cref="ActivityJsonConverter"/>.
 9/// </summary>
 10public class ActivityJsonConverterFactory : JsonConverterFactory
 11{
 12    private readonly IServiceProvider _serviceProvider;
 13
 14    /// <inheritdoc />
 77115    public ActivityJsonConverterFactory(IServiceProvider serviceProvider)
 16    {
 77117        _serviceProvider = serviceProvider;
 77118    }
 19
 20    // Notice that this factory only creates converters when the type to convert is IActivity.
 21    // The ActivityJsonConverter will create concrete activity objects, which then uses regular serialization
 22    /// <inheritdoc />
 14228323    public override bool CanConvert(Type typeToConvert) => typeToConvert == typeof(IActivity);
 24
 25    /// <inheritdoc />
 232226    public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) => ActivatorUtiliti
 27}