2022-05-27 10:36:39 +00:00
|
|
|
using Elsa.Features.Services;
|
2022-06-29 13:36:27 +00:00
|
|
|
using Elsa.Workflows.Core.Activities;
|
2023-01-02 21:24:05 +00:00
|
|
|
using Elsa.Workflows.Core.Services;
|
2022-05-27 10:36:39 +00:00
|
|
|
using Elsa.Workflows.Management.Features;
|
2022-05-26 10:47:31 +00:00
|
|
|
|
2022-12-31 15:16:43 +00:00
|
|
|
// ReSharper disable once CheckNamespace
|
|
|
|
|
namespace Elsa.Extensions;
|
2022-05-26 10:47:31 +00:00
|
|
|
|
2022-11-19 21:30:43 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Provides extensions to the specified <see cref="IModule"/>/
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class ModuleExtensions
|
2022-05-26 10:47:31 +00:00
|
|
|
{
|
2022-11-19 21:30:43 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Adds the workflow management feature to the specified module.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static IModule UseWorkflowManagement(this IModule module, Action<WorkflowManagementFeature>? configure = default)
|
2022-05-26 10:47:31 +00:00
|
|
|
{
|
2022-06-29 13:36:27 +00:00
|
|
|
module.Configure<WorkflowManagementFeature>(management =>
|
|
|
|
|
{
|
|
|
|
|
management.AddActivity<NotFoundActivity>();
|
|
|
|
|
configure?.Invoke(management);
|
|
|
|
|
});
|
2022-05-27 10:36:39 +00:00
|
|
|
return module;
|
2022-05-26 10:47:31 +00:00
|
|
|
}
|
2023-01-05 14:10:55 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adds the workflow instance feature to workflow management module.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static WorkflowManagementFeature UseWorkflowInstances(this WorkflowManagementFeature feature, Action<WorkflowInstanceFeature>? configure = default)
|
|
|
|
|
{
|
|
|
|
|
feature.Module.Configure(configure);
|
|
|
|
|
return feature;
|
|
|
|
|
}
|
2023-01-02 21:24:05 +00:00
|
|
|
|
|
|
|
|
/// <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>());
|
2022-05-26 10:47:31 +00:00
|
|
|
}
|