| | | 1 | | using Elsa.Workflows.Middleware.Workflows; |
| | | 2 | | |
| | | 3 | | namespace Elsa.Workflows.Pipelines.WorkflowExecution; |
| | | 4 | | |
| | | 5 | | /// <inheritdoc /> |
| | | 6 | | public class WorkflowExecutionPipeline : IWorkflowExecutionPipeline |
| | | 7 | | { |
| | | 8 | | private readonly IServiceProvider _serviceProvider; |
| | | 9 | | private WorkflowMiddlewareDelegate? _pipeline; |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Initializes a new instance of the <see cref="WorkflowExecutionPipeline"/> class. |
| | | 13 | | /// </summary> |
| | 421 | 14 | | public WorkflowExecutionPipeline(IServiceProvider serviceProvider, Action<IWorkflowExecutionPipelineBuilder> configu |
| | | 15 | | { |
| | 421 | 16 | | _serviceProvider = serviceProvider; |
| | 421 | 17 | | ConfigurePipelineBuilder = configurePipelineBuilder; |
| | 421 | 18 | | Setup(configurePipelineBuilder); |
| | 421 | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <inheritdoc /> |
| | 436 | 22 | | public WorkflowMiddlewareDelegate Pipeline => _pipeline ??= CreateDefaultPipeline(); |
| | | 23 | | |
| | | 24 | | /// <inheritdoc /> |
| | 4 | 25 | | public Action<IWorkflowExecutionPipelineBuilder> ConfigurePipelineBuilder { get; } |
| | | 26 | | |
| | | 27 | | /// <inheritdoc /> |
| | | 28 | | public WorkflowMiddlewareDelegate Setup(Action<IWorkflowExecutionPipelineBuilder> setup) |
| | | 29 | | { |
| | 421 | 30 | | var builder = new WorkflowExecutionPipelineBuilder(_serviceProvider); |
| | 421 | 31 | | setup(builder); |
| | 421 | 32 | | _pipeline = builder.Build(); |
| | 421 | 33 | | return _pipeline; |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | /// <inheritdoc /> |
| | 436 | 37 | | public async Task ExecuteAsync(WorkflowExecutionContext context) => await Pipeline(context); |
| | | 38 | | |
| | 0 | 39 | | private WorkflowMiddlewareDelegate CreateDefaultPipeline() => Setup(x => x |
| | 0 | 40 | | .UseExceptionHandling() |
| | 0 | 41 | | .UseDefaultActivityScheduler()); |
| | | 42 | | } |