< Summary

Information
Class: Elsa.Extensions.ModuleExtensions
Assembly: Elsa.Workflows.Management
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/Extensions/ModuleExtensions.cs
Line coverage
47%
Covered lines: 10
Uncovered lines: 11
Coverable lines: 21
Total lines: 93
Line coverage: 47.6%
Branch coverage
50%
Covered branches: 5
Total branches: 10
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
UseWorkflowManagement(...)50%22100%
UseWorkflowDefinitions(...)100%210%
UseWorkflowInstances(...)100%210%
AddActivitiesFrom(...)100%22100%
AddActivity(...)0%620%
AddActivityHost(...)100%22100%
RemoveActivity(...)0%620%
AddVariableType(...)100%210%
AddVariableTypeAndAlias(...)100%210%
UseCache(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/Extensions/ModuleExtensions.cs

#LineLine coverage
 1using Elsa.Features.Services;
 2using Elsa.Workflows;
 3using Elsa.Workflows.Activities;
 4using Elsa.Workflows.Management.Features;
 5using Elsa.Workflows.Options;
 6using Microsoft.Extensions.DependencyInjection;
 7using Elsa.Common.Serialization;
 8
 9// ReSharper disable once CheckNamespace
 10namespace Elsa.Extensions;
 11
 12/// <summary>
 13/// Provides extensions to the specified <see cref="IModule"/>/
 14/// </summary>
 15public static class ModuleExtensions
 16{
 17    /// <summary>
 18    /// Adds the workflow management feature to the specified module.
 19    /// </summary>
 20    public static IModule UseWorkflowManagement(this IModule module, Action<WorkflowManagementFeature>? configure = null
 21    {
 3622        module.Configure<WorkflowManagementFeature>(management =>
 3623        {
 3624            management.AddActivity<NotFoundActivity>();
 3625            configure?.Invoke(management);
 7226        });
 3627        return module;
 28    }
 29
 30    /// <summary>
 31    /// Adds the default workflow management feature to the specified module.
 32    /// </summary>
 33    public static WorkflowManagementFeature UseWorkflowDefinitions(this WorkflowManagementFeature feature, Action<Workfl
 34    {
 035        feature.Module.Configure(configure);
 036        return feature;
 37    }
 38
 39    /// <summary>
 40    /// Adds the workflow instance feature to workflow management module.
 41    /// </summary>
 42    public static WorkflowManagementFeature UseWorkflowInstances(this WorkflowManagementFeature feature, Action<Workflow
 43    {
 044        feature.Module.Configure(configure);
 045        return feature;
 46    }
 47
 48    /// <summary>
 49    /// Adds all types implementing <see cref="IActivity"/> to the system.
 50    /// </summary>
 3051    public static IModule AddActivitiesFrom<TMarkerType>(this IModule module) => module.UseWorkflowManagement(management
 52
 53    /// <summary>
 54    /// Adds the specified activity type to the system.
 55    /// </summary>
 056    public static IModule AddActivity<T>(this IModule module) where T : IActivity => module.UseWorkflowManagement(manage
 57
 58    /// <summary>
 59    /// Registers the specified activity host type to the workflow system.
 60    /// </summary>
 1261    public static IModule AddActivityHost<T>(this IModule module) where T : class => module.UseWorkflowManagement(manage
 62
 63    /// <summary>
 64    /// Removes the specified activity type from the system.
 65    /// </summary>
 066    public static IModule RemoveActivity<T>(this IModule module) where T : IActivity => module.UseWorkflowManagement(man
 67
 68    /// <summary>
 69    /// Adds the specified variable type to the system.
 70    /// </summary>
 071    public static IModule AddVariableType<T>(this IModule module, string category) => module.UseWorkflowManagement(manag
 72
 73    /// <summary>
 74    /// Adds a variable type and its alias to the specified module.
 75    /// </summary>
 76    public static IModule AddVariableTypeAndAlias<T>(this IModule module, string alias, string category)
 77    {
 078        module.Services.Configure<SerializationTypeOptions>(options => options.RegisterTypeAlias(typeof(T), alias));
 79
 080        return module
 081            .UseWorkflowManagement(management => management.AddVariableType<T>(category))
 082            .AddTypeAlias<T>(alias);
 83    }
 84
 85    /// <summary>
 86    /// Adds caching stores feature to the workflow management feature.
 87    /// </summary>
 88    public static WorkflowManagementFeature UseCache(this WorkflowManagementFeature feature, Action<CachingWorkflowDefin
 89    {
 690        feature.Module.Configure(configure);
 691        return feature;
 92    }
 93}