| | | 1 | | using System.Reflection; |
| | | 2 | | using Elsa.Features.Abstractions; |
| | | 3 | | using Elsa.Features.Attributes; |
| | | 4 | | using Elsa.Features.Services; |
| | | 5 | | using Elsa.WorkflowProviders.BlobStorage.Contracts; |
| | | 6 | | using Elsa.WorkflowProviders.BlobStorage.Handlers; |
| | | 7 | | using Elsa.WorkflowProviders.BlobStorage.Providers; |
| | | 8 | | using Elsa.Workflows.Management.Features; |
| | | 9 | | using FluentStorage; |
| | | 10 | | using FluentStorage.Blobs; |
| | | 11 | | using Microsoft.Extensions.DependencyInjection; |
| | | 12 | | |
| | | 13 | | namespace Elsa.WorkflowProviders.BlobStorage.Features; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// A feature that enables the FluentStorage workflow definition provider. |
| | | 17 | | /// </summary> |
| | | 18 | | [DependsOn(typeof(WorkflowManagementFeature))] |
| | | 19 | | public class BlobStorageFeature : FeatureBase |
| | | 20 | | { |
| | | 21 | | /// <inheritdoc /> |
| | 1 | 22 | | public BlobStorageFeature(IModule module) : base(module) |
| | | 23 | | { |
| | 1 | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// The blob storage to use. |
| | | 28 | | /// </summary> |
| | 268 | 29 | | public Func<IServiceProvider, IBlobStorage> BlobStorage { get; set; } = _ => StorageFactory.Blobs.DirectoryFiles(Get |
| | | 30 | | |
| | | 31 | | /// <inheritdoc /> |
| | | 32 | | public override void Apply() |
| | | 33 | | { |
| | 267 | 34 | | Services.AddScoped<IBlobStorageProvider>(sp => new BlobStorageProvider(BlobStorage(sp))); |
| | | 35 | | |
| | | 36 | | // Register the JSON format handler (built-in support) |
| | 1 | 37 | | Services.AddScoped<IBlobWorkflowFormatHandler, JsonBlobWorkflowFormatHandler>(); |
| | | 38 | | |
| | 1 | 39 | | Services.AddWorkflowsProvider<BlobStorageWorkflowsProvider>(); |
| | 1 | 40 | | } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Gets the default workflows directory. |
| | | 44 | | /// </summary> |
| | | 45 | | /// <returns>The default workflows directory.</returns> |
| | | 46 | | public static string GetDefaultWorkflowsDirectory() |
| | | 47 | | { |
| | 0 | 48 | | var entryAssemblyDir = Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!; |
| | 0 | 49 | | var directory = Path.Combine(entryAssemblyDir, "Workflows"); |
| | 0 | 50 | | return directory; |
| | | 51 | | } |
| | | 52 | | |
| | | 53 | | } |