< Summary

Information
Class: Elsa.Alterations.Features.AlterationsFeature
Assembly: Elsa.Alterations
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Features/AlterationsFeature.cs
Line coverage
92%
Covered lines: 26
Uncovered lines: 2
Coverable lines: 28
Total lines: 85
Line coverage: 92.8%
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%
get_AlterationPlanStoreFactory()100%11100%
get_AlterationJobStoreFactory()100%11100%
get_AlterationJobDispatcherFactory()100%11100%
AddAlteration()100%210%
Configure()100%11100%
Apply()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Features/AlterationsFeature.cs

#LineLine coverage
 1using Elsa.Alterations.Core.Contracts;
 2using Elsa.Alterations.Core.Entities;
 3using Elsa.Alterations.Core.Extensions;
 4using Elsa.Alterations.Core.Models;
 5using Elsa.Alterations.Core.Stores;
 6using Elsa.Alterations.Extensions;
 7using Elsa.Alterations.Services;
 8using Elsa.Alterations.Workflows;
 9using Elsa.Extensions;
 10using Elsa.Features.Abstractions;
 11using Elsa.Features.Services;
 12using Elsa.Workflows.Options;
 13using Microsoft.Extensions.DependencyInjection;
 14using Elsa.Common.Serialization;
 15
 16namespace Elsa.Alterations.Features;
 17
 18/// <summary>
 19/// Adds the Elsa alterations services.
 20/// </summary>
 21public class AlterationsFeature : FeatureBase
 22{
 23    /// <inheritdoc />
 624    public AlterationsFeature(IModule module) : base(module)
 25    {
 626    }
 27
 28    /// <summary>
 29    /// Gets or sets the factory for the alteration plan store.
 30    /// </summary>
 1631    public Func<IServiceProvider, IAlterationPlanStore> AlterationPlanStoreFactory { get; set; } = sp => sp.GetRequiredS
 32
 33    /// <summary>
 34    /// Gets or sets the factory for the alteration job store.
 35    /// </summary>
 1636    public Func<IServiceProvider, IAlterationJobStore> AlterationJobStoreFactory { get; set; } = sp => sp.GetRequiredSer
 37
 38    /// <summary>
 39    /// Gets or sets the factory for the alteration job dispatcher.
 40    /// </summary>
 1241    public Func<IServiceProvider, IAlterationJobDispatcher> AlterationJobDispatcherFactory { get; set; } = sp => sp.GetR
 42
 43    /// <summary>
 44    /// Adds an alteration and its handler.
 45    /// </summary>
 46    /// <typeparam name="T">The type of alteration.</typeparam>
 47    /// <typeparam name="THandler">The type of alteration handler.</typeparam>
 48    public AlterationsFeature AddAlteration<T, THandler>() where T : class, IAlteration where THandler : class, IAlterat
 49    {
 050        Services.AddAlteration<T, THandler>();
 051        return this;
 52    }
 53
 54    /// <inheritdoc />
 55    public override void Configure()
 56    {
 657        Module.AddFastEndpointsAssembly<AlterationsFeature>();
 658        Module.AddWorkflow<ExecuteAlterationPlanWorkflow>();
 659    }
 60
 61    /// <inheritdoc />
 62    public override void Apply()
 63    {
 664        Services.Configure<SerializationTypeOptions>(options =>
 665        {
 466            options.RegisterTypeAlias(typeof(AlterationPlanParams), nameof(AlterationPlanParams));
 467            options.RegisterLegacySimpleAssemblyQualifiedName(typeof(AlterationPlanParams));
 1068        });
 69
 670        Services.AddScoped<IAlterationPlanManager, AlterationPlanManager>();
 671        Services.AddAlterations();
 672        Services.AddAlterationsCore();
 673        Services.AddScoped<BackgroundAlterationJobDispatcher>();
 674        Services.AddScoped<IAlterationPlanScheduler, DefaultAlterationPlanScheduler>();
 675        Services.AddScoped<IAlterationJobRunner, DefaultAlterationJobRunner>();
 676        Services.AddScoped<IAlterationRunner, DefaultAlterationRunner>();
 77
 678        Services.AddMemoryStore<AlterationPlan, MemoryAlterationPlanStore>();
 679        Services.AddMemoryStore<AlterationJob, MemoryAlterationJobStore>();
 80
 681        Services.AddScoped(AlterationPlanStoreFactory);
 682        Services.AddScoped(AlterationJobStoreFactory);
 683        Services.AddScoped(AlterationJobDispatcherFactory);
 684    }
 85}