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