| | | 1 | | using Elsa.Features.Services; |
| | | 2 | | using Elsa.Workflows; |
| | | 3 | | using Elsa.Workflows.Activities; |
| | | 4 | | using Elsa.Workflows.Management.Features; |
| | | 5 | | |
| | | 6 | | // ReSharper disable once CheckNamespace |
| | | 7 | | namespace Elsa.Extensions; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// Provides extensions to the specified <see cref="IModule"/>/ |
| | | 11 | | /// </summary> |
| | | 12 | | public static class ModuleExtensions |
| | | 13 | | { |
| | | 14 | | /// <summary> |
| | | 15 | | /// Adds the workflow management feature to the specified module. |
| | | 16 | | /// </summary> |
| | | 17 | | public static IModule UseWorkflowManagement(this IModule module, Action<WorkflowManagementFeature>? configure = null |
| | | 18 | | { |
| | 10 | 19 | | module.Configure<WorkflowManagementFeature>(management => |
| | 10 | 20 | | { |
| | 10 | 21 | | management.AddActivity<NotFoundActivity>(); |
| | 10 | 22 | | configure?.Invoke(management); |
| | 20 | 23 | | }); |
| | 10 | 24 | | return module; |
| | | 25 | | } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Adds the default workflow management feature to the specified module. |
| | | 29 | | /// </summary> |
| | | 30 | | public static WorkflowManagementFeature UseWorkflowDefinitions(this WorkflowManagementFeature feature, Action<Workfl |
| | | 31 | | { |
| | 0 | 32 | | feature.Module.Configure(configure); |
| | 0 | 33 | | return feature; |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Adds the workflow instance feature to workflow management module. |
| | | 38 | | /// </summary> |
| | | 39 | | public static WorkflowManagementFeature UseWorkflowInstances(this WorkflowManagementFeature feature, Action<Workflow |
| | | 40 | | { |
| | 0 | 41 | | feature.Module.Configure(configure); |
| | 0 | 42 | | return feature; |
| | | 43 | | } |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Adds all types implementing <see cref="IActivity"/> to the system. |
| | | 47 | | /// </summary> |
| | 10 | 48 | | public static IModule AddActivitiesFrom<TMarkerType>(this IModule module) => module.UseWorkflowManagement(management |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// Adds the specified activity type to the system. |
| | | 52 | | /// </summary> |
| | 0 | 53 | | public static IModule AddActivity<T>(this IModule module) where T : IActivity => module.UseWorkflowManagement(manage |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// Removes the specified activity type from the system. |
| | | 57 | | /// </summary> |
| | 0 | 58 | | public static IModule RemoveActivity<T>(this IModule module) where T : IActivity => module.UseWorkflowManagement(man |
| | | 59 | | |
| | | 60 | | /// <summary> |
| | | 61 | | /// Adds the specified variable type to the system. |
| | | 62 | | /// </summary> |
| | 0 | 63 | | public static IModule AddVariableType<T>(this IModule module, string category) => module.UseWorkflowManagement(manag |
| | | 64 | | |
| | | 65 | | /// <summary> |
| | | 66 | | /// Adds a variable type and its alias to the specified module. |
| | | 67 | | /// </summary> |
| | | 68 | | public static IModule AddVariableTypeAndAlias<T>(this IModule module, string alias, string category) |
| | | 69 | | { |
| | 0 | 70 | | return module |
| | 0 | 71 | | .UseWorkflowManagement(management => management.AddVariableType<T>(category)) |
| | 0 | 72 | | .AddTypeAlias<T>(alias); |
| | | 73 | | } |
| | | 74 | | |
| | | 75 | | /// <summary> |
| | | 76 | | /// Adds caching stores feature to the workflow management feature. |
| | | 77 | | /// </summary> |
| | | 78 | | public static WorkflowManagementFeature UseCache(this WorkflowManagementFeature feature, Action<CachingWorkflowDefin |
| | | 79 | | { |
| | 2 | 80 | | feature.Module.Configure(configure); |
| | 2 | 81 | | return feature; |
| | | 82 | | } |
| | | 83 | | } |