< Summary

Information
Class: Elsa.Workflows.Serialization.Serializers.SerializationOptionsConfigurator
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Serialization/Serializers/SerializationOptionsConfigurator.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
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%
Configure(...)100%11100%
Create()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Serialization/Serializers/SerializationOptionsConfigurator.cs

#LineLine coverage
 1using System.Text.Json;
 2using Elsa.Workflows.Serialization.Converters;
 3using Microsoft.Extensions.DependencyInjection;
 4
 5namespace Elsa.Workflows.Serialization.Serializers;
 6
 7/// <summary>
 8/// Configures the JSON serialization options with support for serializing and deserializing activities and expressions.
 9/// </summary>
 10public class SerializationOptionsConfigurator : SerializationOptionsConfiguratorBase
 11{
 12    private readonly IServiceProvider _serviceProvider;
 13
 14    /// <summary>
 15    /// Initializes a new instance of the <see cref="SerializationOptionsConfigurator"/> class.
 16    /// </summary>
 11417    public SerializationOptionsConfigurator(IServiceProvider serviceProvider)
 18    {
 11419        _serviceProvider = serviceProvider;
 11420    }
 21
 22    /// <inheritdoc />
 23    public override void Configure(JsonSerializerOptions options)
 24    {
 77125        options.Converters.Add(Create<ActivityJsonConverterFactory>());
 77126    }
 27
 77128    private T Create<T>() => ActivatorUtilities.CreateInstance<T>(_serviceProvider);
 29}