elsa-core/src/modules/Elsa/Features/ElsaFeature.cs
Sipke Schoorstra 807722f91e Remove ReadLine activity from automatic registration
The ReadLine activity was removed as it can cause hanging containers when awaiting user input. This change requires explicit opt-in for its usage, improving default workflow behavior and avoiding unintended issues.
2025-05-20 10:45:55 +02:00

49 lines
1.6 KiB
C#

using Elsa.Common.Features;
using Elsa.Extensions;
using Elsa.Features.Abstractions;
using Elsa.Features.Attributes;
using Elsa.Features.Services;
using Elsa.Workflows.Activities;
using Elsa.Workflows.Features;
using Elsa.Workflows.Management.Features;
using Elsa.Workflows.Runtime.Features;
namespace Elsa.Features;
/// <summary>
/// Represents Elsa as a feature of the system.
/// </summary>
[DependsOn(typeof(MediatorFeature))]
[DependsOn(typeof(WorkflowsFeature))]
[DependsOn(typeof(FlowchartFeature))]
[DependsOn(typeof(DefaultWorkflowRuntimeFeature))]
[DependsOn(typeof(WorkflowManagementFeature))]
public class ElsaFeature : FeatureBase
{
/// <summary>
/// Set this to true to opt out of automatically registering activities from Elsa.Workflows.Core.
/// </summary>
public bool DisableAutomaticActivityRegistration { get; set; }
/// <inheritdoc />
public ElsaFeature(IModule module) : base(module)
{
}
/// <inheritdoc />
public override void Configure()
{
Module
.UseWorkflows(workflows => workflows
.WithDefaultWorkflowExecutionPipeline()
.WithDefaultActivityExecutionPipeline())
.UseWorkflowManagement(management =>
{
if (!DisableAutomaticActivityRegistration)
management
.AddActivitiesFrom<WriteLine>()
.RemoveActivity<ReadLine>() // ReadLine is not commonly used and can cause "hanging" containers when awaiting user input. Better to opt-in explicitly.
;
});
}
}