< Summary

Information
Class: Elsa.Workflows.ShellFeatures.WorkflowsFeature
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/ShellFeatures/WorkflowsFeature.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 108
Coverable lines: 108
Total lines: 180
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

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/ShellFeatures/WorkflowsFeature.cs

#LineLine coverage
 1using CShells.Features;
 2using Elsa.Common;
 3using Elsa.Common.Serialization;
 4using Elsa.Common.ShellFeatures;
 5using Elsa.Expressions.ShellFeatures;
 6using Elsa.Extensions;
 7using Elsa.Workflows.ActivationValidators;
 8using Elsa.Workflows.Activities.Flowchart.Options;
 9using Elsa.Workflows.Activities.Flowchart.Serialization;
 10using Elsa.Workflows.Builders;
 11using Elsa.Workflows.CommitStates;
 12using Elsa.Workflows.IncidentStrategies;
 13using Elsa.Workflows.LogPersistence;
 14using Elsa.Workflows.LogPersistence.Strategies;
 15using Elsa.Workflows.Middleware.Activities;
 16using Elsa.Workflows.Middleware.Workflows;
 17using Elsa.Workflows.Pipelines.ActivityExecution;
 18using Elsa.Workflows.Pipelines.WorkflowExecution;
 19using Elsa.Workflows.PortResolvers;
 20using Elsa.Workflows.Serialization.Configurators;
 21using Elsa.Workflows.Serialization.Helpers;
 22using Elsa.Workflows.Serialization.Serializers;
 23using Elsa.Workflows.Services;
 24using Elsa.Workflows.UIHints.CheckList;
 25using Elsa.Workflows.UIHints.Dictionary;
 26using Elsa.Workflows.UIHints.Dropdown;
 27using Elsa.Workflows.UIHints.JsonEditor;
 28using Elsa.Workflows.UIHints.RadioList;
 29using Microsoft.Extensions.DependencyInjection;
 30
 31namespace Elsa.Workflows.ShellFeatures;
 32
 33[ShellFeature(DependsOn =
 34[
 35    "SystemClock",
 36    "Expressions",
 37    "Mediator",
 38    "DefaultFormatters",
 39    "Multitenancy",
 40    "CommitStrategies"
 41])]
 42public class WorkflowsFeature : IShellFeature
 43{
 44    /// <summary>
 45    /// A delegate to configure the <see cref="IWorkflowExecutionPipeline"/>.
 46    /// </summary>
 047    public Action<IWorkflowExecutionPipelineBuilder> WorkflowExecutionPipeline { get; set; } = builder => builder
 048        .UseExceptionHandling()
 049        .UseDefaultActivityScheduler();
 50
 51    /// <summary>
 52    /// A delegate to configure the <see cref="IActivityExecutionPipeline"/>.
 53    /// </summary>
 054    public Action<IActivityExecutionPipelineBuilder> ActivityExecutionPipeline { get; set; } = builder => builder.UseDef
 55
 56    /// <summary>
 57    /// A factory that instantiates a concrete <see cref="IStandardInStreamProvider"/>.
 58    /// </summary>
 059    public Func<IServiceProvider, IStandardInStreamProvider> StandardInStreamProvider { get; set; } = _ => new StandardI
 60
 61    /// <summary>
 62    /// A factory that instantiates a concrete <see cref="IStandardOutStreamProvider"/>.
 63    /// </summary>
 064    public Func<IServiceProvider, IStandardOutStreamProvider> StandardOutStreamProvider { get; set; } = _ => new Standar
 65
 66    /// <summary>
 67    /// A factory that instantiates a concrete <see cref="ILoggerStateGenerator{WorkflowExecutionContext}"/>.
 68    /// </summary>
 069    public Func<IServiceProvider, ILoggerStateGenerator<WorkflowExecutionContext>> WorkflowLoggerStateGenerator { get; s
 70
 71    /// <summary>
 72    /// A factory that instantiates a concrete <see cref="ILoggerStateGenerator{ActivityExecutionContext}"/>.
 73    /// </summary>
 074    public Func<IServiceProvider, ILoggerStateGenerator<ActivityExecutionContext>> ActivityLoggerStateGenerator { get; s
 75
 76    public void ConfigureServices(IServiceCollection services)
 77    {
 078        services
 079            // Core.
 080            .AddScoped<IActivityInvoker, ActivityInvoker>()
 081            .AddScoped<IWorkflowRunner, WorkflowRunner>()
 082            .AddScoped<IActivityTestRunner, ActivityTestRunner>()
 083            .AddScoped<IActivityVisitor, ActivityVisitor>()
 084            .AddScoped<IIdentityGraphService, IdentityGraphService>()
 085            .AddScoped<IWorkflowGraphBuilder, WorkflowGraphBuilder>()
 086            .AddScoped<IWorkflowStateExtractor, WorkflowStateExtractor>()
 087            .AddScoped<IActivitySchedulerFactory, ActivitySchedulerFactory>()
 088            .AddSingleton<IWorkflowExecutionContextSchedulerStrategy, WorkflowExecutionContextSchedulerStrategy>()
 089            .AddSingleton<IActivityExecutionContextSchedulerStrategy, ActivityExecutionContextSchedulerStrategy>()
 090            .AddSingleton<IHasher, Hasher>()
 091            .AddSingleton<IStimulusHasher, StimulusHasher>()
 092            .AddSingleton<IIdentityGenerator, ShortGuidIdentityGenerator>()
 093            .AddSingleton<IBookmarkPayloadSerializer>(sp => ActivatorUtilities.CreateInstance<BookmarkPayloadSerializer>
 094            .AddSingleton<IActivityDescriber, ActivityDescriber>()
 095            .AddSingleton<IActivityRegistry, ActivityRegistry>()
 096            .AddScoped<IActivityRegistryLookupService, ActivityRegistryLookupService>()
 097            .AddSingleton<IPropertyDefaultValueResolver, PropertyDefaultValueResolver>()
 098            .AddSingleton<IPropertyUIHandlerResolver, PropertyUIHandlerResolver>()
 099            .AddSingleton<IActivityFactory, ActivityFactory>()
 0100            .AddTransient<WorkflowBuilder>()
 0101            .AddScoped(typeof(Func<IWorkflowBuilder>), sp => () => sp.GetRequiredService<WorkflowBuilder>())
 0102            .AddScoped<IWorkflowBuilderFactory, WorkflowBuilderFactory>()
 0103            .AddScoped<IVariablePersistenceManager, VariablePersistenceManager>()
 0104            .AddScoped<IIncidentStrategyResolver, DefaultIncidentStrategyResolver>()
 0105            .AddScoped<IActivityStateFilterManager, DefaultActivityStateFilterManager>()
 0106            .AddScoped<IWorkflowInstanceVariableReader, DefaultWorkflowInstanceVariableReader>()
 0107            .AddScoped<IWorkflowInstanceVariableWriter, DefaultWorkflowInstanceVariableWriter>()
 0108            .AddScoped<DefaultActivityInputEvaluator>()
 0109
 0110            // Incident Strategies.
 0111            .AddTransient<IIncidentStrategy, FaultStrategy>()
 0112            .AddTransient<IIncidentStrategy, ContinueWithIncidentsStrategy>()
 0113
 0114            // Pipelines.
 0115            .AddScoped<IActivityExecutionPipeline>(sp => new ActivityExecutionPipeline(sp, ActivityExecutionPipeline))
 0116            .AddScoped<IWorkflowExecutionPipeline>(sp => new WorkflowExecutionPipeline(sp, WorkflowExecutionPipeline))
 0117
 0118            // Built-in activity services.
 0119            .AddScoped<IActivityResolver, PropertyBasedActivityResolver>()
 0120            .AddScoped<IActivityResolver, SwitchActivityResolver>()
 0121            .AddSerializationOptionsConfigurator<AdditionalConvertersConfigurator>()
 0122            .AddSerializationOptionsConfigurator<CustomConstructorConfigurator>()
 0123            .AddSerializationOptionsConfigurator<FlowchartSerializationOptionConfigurator>()
 0124
 0125            // Domain event handlers.
 0126            .AddHandlersFrom<WorkflowsFeature>()
 0127
 0128            // Stream providers.
 0129            .AddScoped(StandardInStreamProvider)
 0130            .AddScoped(StandardOutStreamProvider)
 0131
 0132            // Storage drivers.
 0133            .AddScoped<IStorageDriverManager, StorageDriverManager>()
 0134            .AddStorageDriver<WorkflowStorageDriver>()
 0135            .AddStorageDriver<WorkflowInstanceStorageDriver>()
 0136            .AddStorageDriver<MemoryStorageDriver>()
 0137
 0138            // Serialization.
 0139            .AddSingleton<IWorkflowStateSerializer, JsonWorkflowStateSerializer>()
 0140            .AddSingleton<IPayloadSerializer, JsonPayloadSerializer>()
 0141            .AddSingleton<IActivitySerializer, JsonActivitySerializer>()
 0142            .AddSingleton<IApiSerializer, ApiSerializer>()
 0143            .AddSingleton<ISafeSerializer, SafeSerializer>()
 0144            .AddSingleton<IJsonSerializer, StandardJsonSerializer>()
 0145            .AddSingleton<SyntheticPropertiesWriter>()
 0146            .AddSingleton<ActivityWriter>()
 0147
 0148            // Instantiation strategies.
 0149            .AddScoped<IWorkflowActivationStrategy, AllowAlwaysStrategy>()
 0150
 0151            // UI.
 0152            .AddScoped<IUIHintHandler, DropDownUIHintHandler>()
 0153            .AddScoped<IUIHintHandler, CheckListUIHintHandler>()
 0154            .AddScoped<IUIHintHandler, RadioListUIHintHandler>()
 0155            .AddScoped<IUIHintHandler, JsonEditorUIHintHandler>()
 0156            .AddScoped<IPropertyUIHandler, StaticCheckListOptionsProvider>()
 0157            .AddScoped<IPropertyUIHandler, StaticRadioListOptionsProvider>()
 0158            .AddScoped<IPropertyUIHandler, StaticDropDownOptionsProvider>()
 0159            .AddScoped<IPropertyUIHandler, JsonCodeOptionsProvider>()
 0160            .AddScoped<DictionaryValueEvaluator>()
 0161            .AddSingleton<IActivityDescriptorModifier, DictionaryUIHintInputModifier>()
 0162
 0163            // Logger state generators.
 0164            .AddSingleton(WorkflowLoggerStateGenerator)
 0165            .AddSingleton(ActivityLoggerStateGenerator)
 0166
 0167            // Log Persistence Strategies.
 0168            .AddScoped<ILogPersistenceStrategyService, DefaultLogPersistenceStrategyService>()
 0169            .AddScoped<ILogPersistenceStrategy, Include>()
 0170            .AddScoped<ILogPersistenceStrategy, Exclude>()
 0171            .AddScoped<ILogPersistenceStrategy, Inherit>()
 0172            .AddScoped<ILogPersistenceStrategy, Configuration>()
 0173
 0174            // Logging
 0175            .AddLogging();
 176
 177        // Overridable services
 0178        services.AddScoped<ICommitStateHandler, NoopCommitStateHandler>();
 0179    }
 180}