elsa-core/src/modules/Elsa.Workflows.Management/Extensions/ModuleExtensions.cs
Sipke Schoorstra fad27d0fb0
Refactor composite activity input and scoped memory (#3815)
* Incremental work

* Enable control over when to include full compositie root

* Cleanup

* Update WorkflowDefinitionActivity

* Implement input as variables

* Delete unused class

* Remove less common types

* Rename ExpandoObject to JSON

* Implement variable scoping

* Remove parent/child relationship from MemoryRegister

* Add support for sending input to "trigger event" endpoint

* Add support for configuring input storage driver

* Remove unused namespace imports

* Auto-register activity types when running a workflow

* Fix missing variables from containers
2023-03-20 19:55:11 +01:00

54 lines
2 KiB
C#

using Elsa.Features.Services;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Contracts;
using Elsa.Workflows.Management.Features;
// ReSharper disable once CheckNamespace
namespace Elsa.Extensions;
/// <summary>
/// Provides extensions to the specified <see cref="IModule"/>/
/// </summary>
public static class ModuleExtensions
{
/// <summary>
/// Adds the workflow management feature to the specified module.
/// </summary>
public static IModule UseWorkflowManagement(this IModule module, Action<WorkflowManagementFeature>? configure = default)
{
module.Configure<WorkflowManagementFeature>(management =>
{
management.AddActivity<NotFoundActivity>();
configure?.Invoke(management);
});
return module;
}
/// <summary>
/// Adds the default workflow management feature to the specified module.
/// </summary>
public static WorkflowManagementFeature UseWorkflowDefinitions(this WorkflowManagementFeature feature, Action<WorkflowDefinitionsFeature>? configure = default)
{
feature.Module.Configure(configure);
return feature;
}
/// <summary>
/// Adds the workflow instance feature to workflow management module.
/// </summary>
public static WorkflowManagementFeature UseWorkflowInstances(this WorkflowManagementFeature feature, Action<WorkflowInstancesFeature>? configure = default)
{
feature.Module.Configure(configure);
return feature;
}
/// <summary>
/// Adds all types implementing <see cref="IActivity"/> to the system.
/// </summary>
public static IModule AddActivitiesFrom<TMarkerType>(this IModule module) => module.UseWorkflowManagement(management => management.AddActivitiesFrom<TMarkerType>());
/// <summary>
/// Adds the specified activity type to the system.
/// </summary>
public static IModule AddActivity<T>(this IModule module) where T:IActivity => module.UseWorkflowManagement(management => management.AddActivity<T>());
}