< Summary

Information
Class: Elsa.Workflows.Management.ShellFeatures.WorkflowManagementFeature
Assembly: Elsa.Workflows.Management
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/ShellFeatures/WorkflowManagementFeature.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 66
Coverable lines: 66
Total lines: 133
Line coverage: 0%
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
get_VariableDescriptors()100%210%
.ctor()100%210%
ConfigureServices(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/ShellFeatures/WorkflowManagementFeature.cs

#LineLine coverage
 1using System.Dynamic;
 2using System.Text.Json;
 3using System.Text.Json.Nodes;
 4using CShells.Features;
 5using Elsa.Caching.Features;
 6using Elsa.Common.Features;
 7using Elsa.Expressions.Contracts;
 8using Elsa.Extensions;
 9using Elsa.Features.Attributes;
 10using Elsa.Workflows.Features;
 11using Elsa.Workflows.Management.Activities.WorkflowDefinitionActivity;
 12using Elsa.Workflows.Management.Contracts;
 13using Elsa.Workflows.Management.Entities;
 14using Elsa.Workflows.Management.Extensions;
 15using Elsa.Workflows.Management.Features;
 16using Elsa.Workflows.Management.Handlers.Notifications;
 17using Elsa.Workflows.Management.Mappers;
 18using Elsa.Workflows.Management.Materializers;
 19using Elsa.Workflows.Management.Models;
 20using Elsa.Workflows.Management.Options;
 21using Elsa.Workflows.Management.Providers;
 22using Elsa.Workflows.Management.Services;
 23using Elsa.Workflows.Management.Stores;
 24using Elsa.Workflows.Serialization.Serializers;
 25using JetBrains.Annotations;
 26using Microsoft.Extensions.DependencyInjection;
 27
 28namespace Elsa.Workflows.Management.ShellFeatures;
 29
 30/// <summary>
 31/// Installs and configures the workflow management feature.
 32/// </summary>
 33[ShellFeature(
 34    DisplayName = "Workflow Management",
 35    Description = "Provides comprehensive workflow definition and instance management capabilities",
 36    DependsOn =
 37    [
 38        "StringCompression",
 39        "Mediator",
 40        "MemoryCache",
 41        "SystemClock",
 42        "Workflows",
 43        "WorkflowDefinitions",
 44        "WorkflowInstances"
 45    ])]
 46[UsedImplicitly]
 47public class WorkflowManagementFeature : IShellFeature
 48{
 49    private const string PrimitivesCategory = "Primitives";
 50    private const string LookupsCategory = "Lookups";
 51    private const string DynamicCategory = "Dynamic";
 52    private const string DataCategory = "Data";
 53    private const string SystemCategory = "System";
 54
 55    /// <summary>
 56    /// A set of variable types to make available to the system.
 57    /// </summary>
 058    public HashSet<VariableDescriptor> VariableDescriptors { get; } =
 059    [
 060        new(typeof(object), PrimitivesCategory, "The root class for all objects in the CLR System."),
 061        new(typeof(string), PrimitivesCategory, "Represents a static string of characters."),
 062        new(typeof(bool), PrimitivesCategory, "Represents a true or false value."),
 063        new(typeof(int), PrimitivesCategory, "A 32 bit integer."),
 064        new(typeof(long), PrimitivesCategory, "A 64 bit integer."),
 065        new(typeof(float), PrimitivesCategory, "A 32 bit floating point number."),
 066        new(typeof(double), PrimitivesCategory, "A 64 bit floating point number."),
 067        new(typeof(decimal), PrimitivesCategory, "A decimal number."),
 068        new(typeof(Guid), PrimitivesCategory, "Represents a Globally Unique Identifier."),
 069        new(typeof(DateTime), PrimitivesCategory, "A value type that represents a date and time."),
 070        new(typeof(DateTimeOffset), PrimitivesCategory, "A value type that consists of a DateTime and a time zone offset
 071        new(typeof(TimeSpan), PrimitivesCategory, "Represents a duration of time."),
 072        new(typeof(IDictionary<string, string>), LookupsCategory, "A dictionary with string key and values."),
 073        new(typeof(IDictionary<string, object>), LookupsCategory, "A dictionary with string key and object values."),
 074        new(typeof(ExpandoObject), DynamicCategory, "A dictionary that can be typed as dynamic to access members using d
 075        new(typeof(JsonElement), DynamicCategory, "A JSON element for reading a JSON structure."),
 076        new(typeof(JsonNode), DynamicCategory, "A JSON node for reading and writing a JSON structure."),
 077        new(typeof(JsonObject), DynamicCategory, "A JSON object for reading and writing a JSON structure."),
 078        new(typeof(byte[]), DataCategory, "A byte array."),
 079        new(typeof(Stream), DataCategory, "A stream.")
 080    ];
 81
 82
 83    public void ConfigureServices(IServiceCollection services)
 84    {
 085        services
 086            .AddMemoryStore<WorkflowDefinition, MemoryWorkflowDefinitionStore>()
 087            .AddMemoryStore<WorkflowInstance, MemoryWorkflowInstanceStore>()
 088            .AddActivityProvider<TypedActivityProvider>()
 089            .AddActivityProvider<WorkflowDefinitionActivityProvider>()
 090            .AddScoped<WorkflowDefinitionActivityDescriptorFactory>()
 091            .AddScoped<WorkflowDefinitionActivityProvider>()
 092            .AddScoped<IWorkflowDefinitionActivityRegistryUpdater, WorkflowDefinitionActivityRegistryUpdater>()
 093            .AddScoped<IMaterializerRegistry, MaterializerRegistry>()
 094            .AddScoped<IWorkflowDefinitionService, WorkflowDefinitionService>()
 095            .AddScoped<IWorkflowSerializer, WorkflowSerializer>()
 096            .AddScoped<IWorkflowValidator, WorkflowValidator>()
 097            .AddScoped<IWorkflowReferenceQuery, DefaultWorkflowReferenceQuery>()
 098            .AddScoped<IWorkflowReferenceGraphBuilder, WorkflowReferenceGraphBuilder>()
 099            .AddScoped<IWorkflowDefinitionPublisher, WorkflowDefinitionPublisher>()
 0100            .AddScoped<IWorkflowDefinitionImporter, WorkflowDefinitionImporter>()
 0101            .AddScoped<IWorkflowDefinitionManager, WorkflowDefinitionManager>()
 0102            .AddScoped<IWorkflowInstanceManager, WorkflowInstanceManager>()
 0103            .AddScoped<IWorkflowReferenceUpdater, WorkflowReferenceUpdater>()
 0104            .AddScoped<IActivityRegistryPopulator, ActivityRegistryPopulator>()
 0105            .AddSingleton<IExpressionDescriptorRegistry, ExpressionDescriptorRegistry>()
 0106            .AddSingleton<IExpressionDescriptorProvider, DefaultExpressionDescriptorProvider>()
 0107            .AddSerializationOptionsConfigurator<SerializationOptionsConfigurator>()
 0108            .AddScoped<IWorkflowMaterializer, TypedWorkflowMaterializer>()
 0109            .AddScoped<IWorkflowMaterializer, ClrWorkflowMaterializer>()
 0110            .AddScoped<IWorkflowMaterializer, JsonWorkflowMaterializer>()
 0111            .AddScoped<IActivityResolver, WorkflowDefinitionActivityResolver>()
 0112            .AddScoped<IWorkflowInstanceVariableManager, WorkflowInstanceVariableManager>()
 0113            .AddScoped<WorkflowDefinitionMapper>()
 0114            .AddSingleton<VariableDefinitionMapper>()
 0115            .AddSingleton<WorkflowStateMapper>()
 0116            .AddScoped<IWorkflowInstanceStore, MemoryWorkflowInstanceStore>()
 0117            .AddScoped<IWorkflowDefinitionStore, MemoryWorkflowDefinitionStore>();
 118
 0119        services
 0120            .AddNotificationHandler<DeleteWorkflowInstances>()
 0121            .AddNotificationHandler<RefreshActivityRegistry>()
 0122            .AddNotificationHandler<UpdateConsumingWorkflows>()
 0123            .AddNotificationHandler<ValidateWorkflow>();
 124
 125        // Register built-in activities from the Workflows and WorkflowManagement assemblies.
 0126        services
 0127            .AddActivitiesFrom<WorkflowsFeature>()
 0128            .AddActivitiesFrom<WorkflowManagementFeature>();
 129
 130        // Register the default variable descriptors declared on this feature.
 0131        services.AddVariableDescriptors(VariableDescriptors);
 0132    }
 133}