elsa-core/src/modules/Elsa.Workflows.Management/Extensions/ModuleExtensions.cs

45 lines
1.7 KiB
C#
Raw Normal View History

using Elsa.Features.Services;
2022-06-29 13:36:27 +00:00
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Services;
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)
{
2022-06-29 13:36:27 +00:00
module.Configure<WorkflowManagementFeature>(management =>
{
management.AddActivity<NotFoundActivity>();
configure?.Invoke(management);
});
return module;
}
/// <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;
}
/// <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>());
}