| | | 1 | | using Elsa.Extensions; |
| | | 2 | | using Elsa.Features.Abstractions; |
| | | 3 | | using Elsa.Features.Services; |
| | | 4 | | using Elsa.Workflows.CommitStates.Strategies; |
| | | 5 | | using Elsa.Workflows.CommitStates.Tasks; |
| | | 6 | | using Microsoft.Extensions.DependencyInjection; |
| | | 7 | | |
| | | 8 | | namespace Elsa.Workflows.CommitStates; |
| | | 9 | | |
| | 114 | 10 | | public class CommitStrategiesFeature(IModule module) : FeatureBase(module) |
| | | 11 | | { |
| | | 12 | | public void AddStandardStrategies() |
| | | 13 | | { |
| | | 14 | | // Workflow commit strategies. |
| | 1 | 15 | | Add(new WorkflowExecutingWorkflowStrategy()); |
| | 1 | 16 | | Add(new WorkflowExecutedWorkflowStrategy()); |
| | 1 | 17 | | Add(new ActivityExecutingWorkflowStrategy()); |
| | 1 | 18 | | Add(new ActivityExecutedWorkflowStrategy()); |
| | | 19 | | |
| | | 20 | | // Activity commit strategies. |
| | 1 | 21 | | Add(new CommitAlwaysActivityStrategy()); |
| | 1 | 22 | | Add(new CommitNeverActivityStrategy()); |
| | 1 | 23 | | Add(new ExecutingActivityStrategy()); |
| | 1 | 24 | | Add(new ExecutedActivityStrategy()); |
| | 1 | 25 | | } |
| | | 26 | | |
| | | 27 | | public void Add(IWorkflowCommitStrategy strategy) |
| | | 28 | | { |
| | 4 | 29 | | var registration = ObjectRegistrationFactory.Describe(strategy); |
| | 4 | 30 | | Add(registration); |
| | 4 | 31 | | } |
| | | 32 | | |
| | | 33 | | public void Add(string displayName, IWorkflowCommitStrategy strategy) |
| | | 34 | | { |
| | 1 | 35 | | var registration = ObjectRegistrationFactory.Describe(strategy); |
| | 1 | 36 | | registration.Metadata.DisplayName = displayName; |
| | 1 | 37 | | Add(registration); |
| | 1 | 38 | | } |
| | | 39 | | |
| | | 40 | | public void Add(string displayName, string description, IWorkflowCommitStrategy strategy) |
| | | 41 | | { |
| | 0 | 42 | | var registration = ObjectRegistrationFactory.Describe(strategy); |
| | 0 | 43 | | registration.Metadata.DisplayName = displayName; |
| | 0 | 44 | | registration.Metadata.Description = description; |
| | 0 | 45 | | Add(registration); |
| | 0 | 46 | | } |
| | | 47 | | |
| | | 48 | | public void Add(string name, string displayName, string description, IWorkflowCommitStrategy strategy) |
| | | 49 | | { |
| | 0 | 50 | | var registration = ObjectRegistrationFactory.Describe(strategy); |
| | 0 | 51 | | registration.Metadata.Name = name; |
| | 0 | 52 | | registration.Metadata.DisplayName = displayName; |
| | 0 | 53 | | registration.Metadata.Description = description; |
| | 0 | 54 | | Add(registration); |
| | 0 | 55 | | } |
| | | 56 | | |
| | | 57 | | public void Add(WorkflowCommitStrategyRegistration registration) |
| | | 58 | | { |
| | 10 | 59 | | Services.Configure<CommitStateOptions>(options => options.WorkflowCommitStrategies[registration.Metadata.Name] = |
| | 5 | 60 | | } |
| | | 61 | | |
| | | 62 | | public void Add(IActivityCommitStrategy strategy) |
| | | 63 | | { |
| | 4 | 64 | | var registration = ObjectRegistrationFactory.Describe(strategy); |
| | 4 | 65 | | Add(registration); |
| | 4 | 66 | | } |
| | | 67 | | |
| | | 68 | | public void Add(string displayName, IActivityCommitStrategy strategy) |
| | | 69 | | { |
| | 0 | 70 | | var registration = ObjectRegistrationFactory.Describe(strategy); |
| | 0 | 71 | | registration.Metadata.DisplayName = displayName; |
| | 0 | 72 | | Add(registration); |
| | 0 | 73 | | } |
| | | 74 | | |
| | | 75 | | public void Add(string displayName, string description, IActivityCommitStrategy strategy) |
| | | 76 | | { |
| | 0 | 77 | | var registration = ObjectRegistrationFactory.Describe(strategy); |
| | 0 | 78 | | registration.Metadata.DisplayName = displayName; |
| | 0 | 79 | | registration.Metadata.Description = description; |
| | 0 | 80 | | Add(registration); |
| | 0 | 81 | | } |
| | | 82 | | |
| | | 83 | | public void Add(string name, string displayName, string description, IActivityCommitStrategy strategy) |
| | | 84 | | { |
| | 0 | 85 | | var registration = ObjectRegistrationFactory.Describe(strategy); |
| | 0 | 86 | | registration.Metadata.Name = name; |
| | 0 | 87 | | registration.Metadata.DisplayName = displayName; |
| | 0 | 88 | | registration.Metadata.Description = description; |
| | 0 | 89 | | Add(registration); |
| | 0 | 90 | | } |
| | | 91 | | |
| | | 92 | | public void Add(ActivityCommitStrategyRegistration registration) |
| | | 93 | | { |
| | 8 | 94 | | Services.Configure<CommitStateOptions>(options => options.ActivityCommitStrategies[registration.Metadata.Name] = |
| | 4 | 95 | | } |
| | | 96 | | |
| | | 97 | | public override void Apply() |
| | | 98 | | { |
| | 114 | 99 | | Services.AddSingleton<ICommitStrategyRegistry, DefaultCommitStrategyRegistry>(); |
| | 114 | 100 | | Services.AddStartupTask<PopulateCommitStrategyRegistry>(); |
| | 114 | 101 | | } |
| | | 102 | | } |