| | | 1 | | using CShells.Features; |
| | | 2 | | using Elsa.Common.ShellFeatures; |
| | | 3 | | using Elsa.Extensions; |
| | | 4 | | using Elsa.Labels.Contracts; |
| | | 5 | | using Elsa.Labels.Entities; |
| | | 6 | | using Elsa.Labels.Services; |
| | | 7 | | using Elsa.Platform.PackageManifest.Generator.Hints; |
| | | 8 | | using Elsa.Workflows.Management; |
| | | 9 | | using JetBrains.Annotations; |
| | | 10 | | using Microsoft.Extensions.DependencyInjection; |
| | | 11 | | |
| | | 12 | | namespace Elsa.Labels.ShellFeatures; |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Enables functionality to tag workflows with labels. |
| | | 16 | | /// </summary> |
| | | 17 | | [ManifestFeatureCategory("Labels")] |
| | | 18 | | [ShellFeature( |
| | | 19 | | DisplayName = "Labels", |
| | | 20 | | Description = "Enables functionality to tag workflows with labels", |
| | | 21 | | DependsOn = [typeof(MediatorFeature)])] |
| | | 22 | | [UsedImplicitly] |
| | | 23 | | public class LabelsFeature : IShellFeature |
| | | 24 | | { |
| | | 25 | | /// <summary> |
| | | 26 | | /// A delegate that provides an instance of an implementation of <see cref="ILabelStore"/>. |
| | | 27 | | /// </summary> |
| | 0 | 28 | | public Func<IServiceProvider, ILabelStore> LabelStore { get; set; } = sp => sp.GetRequiredService<InMemoryLabelStore |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// A delegate that provides an instance of an implementation of <see cref="IWorkflowDefinitionLabelStore"/>. |
| | | 32 | | /// </summary> |
| | 0 | 33 | | public Func<IServiceProvider, IWorkflowDefinitionLabelStore> WorkflowDefinitionLabelStore { get; set; } = sp => sp.G |
| | | 34 | | |
| | | 35 | | public void ConfigureServices(IServiceCollection services) |
| | | 36 | | { |
| | 0 | 37 | | services |
| | 0 | 38 | | .AddMemoryStore<Label, InMemoryLabelStore>() |
| | 0 | 39 | | .AddMemoryStore<WorkflowDefinitionLabel, InMemoryWorkflowDefinitionLabelStore>() |
| | 0 | 40 | | .AddScoped(LabelStore) |
| | 0 | 41 | | .AddScoped(WorkflowDefinitionLabelStore) |
| | 0 | 42 | | .AddScoped<IWorkflowDefinitionFilterProvider, WorkflowDefinitionLabelFilterProvider>(); |
| | | 43 | | |
| | 0 | 44 | | services.AddNotificationHandlersFrom(GetType()); |
| | 0 | 45 | | } |
| | | 46 | | } |
| | | 47 | | |