< Summary

Information
Class: Elsa.Alterations.Core.Extensions.ServiceCollectionExtensions
Assembly: Elsa.Alterations.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations.Core/Extensions/ServiceCollectionExtensions.cs
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 37
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
AddAlterationsCore(...)100%11100%
AddAlteration(...)100%22100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations.Core/Extensions/ServiceCollectionExtensions.cs

#LineLine coverage
 1using Elsa.Alterations.Core.Contracts;
 2using Elsa.Alterations.Core.Options;
 3using Elsa.Alterations.Core.Serialization;
 4using Elsa.Alterations.Core.Services;
 5using Elsa.Extensions;
 6using Microsoft.Extensions.DependencyInjection;
 7
 8namespace Elsa.Alterations.Core.Extensions;
 9
 10/// <summary>
 11/// Extension methods for <see cref="IServiceCollection"/>.
 12/// </summary>
 13public static class ServiceCollectionExtensions
 14{
 15    /// <summary>
 16    /// Adds the core Elsa alterations services.
 17    /// </summary>
 18    public static IServiceCollection AddAlterationsCore(this IServiceCollection services)
 19    {
 220        services.Configure<AlterationOptions>(_ => { }); // Ensure that the options are configured even if the applicati
 121        services.AddScoped<IAlteredWorkflowDispatcher, AlteredWorkflowDispatcher>();
 122        services.AddScoped<IWorkflowInstanceFinder, WorkflowInstanceFinder>();
 123        services.AddSingleton<IAlterationSerializer, AlterationSerializer>();
 124        services.AddSerializationOptionsConfigurator<AlterationSerializationOptionConfigurator>();
 125        return services;
 26    }
 27
 28    /// <summary>
 29    /// Adds an alteration handler.
 30    /// </summary>
 31    public static IServiceCollection AddAlteration<T, THandler>(this IServiceCollection services) where T : IAlteration 
 32    {
 1033        services.Configure<AlterationOptions>(options => options.AlterationTypes.Add(typeof(T)));
 534        services.AddScoped<IAlterationHandler, THandler>();
 535        return services;
 36    }
 37}