| | | 1 | | using Elsa.Alterations.Core.Contracts; |
| | | 2 | | using Elsa.Alterations.Core.Options; |
| | | 3 | | using Elsa.Alterations.Core.Serialization; |
| | | 4 | | using Elsa.Alterations.Core.Services; |
| | | 5 | | using Elsa.Extensions; |
| | | 6 | | using Microsoft.Extensions.DependencyInjection; |
| | | 7 | | |
| | | 8 | | namespace Elsa.Alterations.Core.Extensions; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Extension methods for <see cref="IServiceCollection"/>. |
| | | 12 | | /// </summary> |
| | | 13 | | public static class ServiceCollectionExtensions |
| | | 14 | | { |
| | | 15 | | /// <summary> |
| | | 16 | | /// Adds the core Elsa alterations services. |
| | | 17 | | /// </summary> |
| | | 18 | | public static IServiceCollection AddAlterationsCore(this IServiceCollection services) |
| | | 19 | | { |
| | 2 | 20 | | services.Configure<AlterationOptions>(_ => { }); // Ensure that the options are configured even if the applicati |
| | 1 | 21 | | services.AddScoped<IAlteredWorkflowDispatcher, AlteredWorkflowDispatcher>(); |
| | 1 | 22 | | services.AddScoped<IWorkflowInstanceFinder, WorkflowInstanceFinder>(); |
| | 1 | 23 | | services.AddSingleton<IAlterationSerializer, AlterationSerializer>(); |
| | 1 | 24 | | services.AddSerializationOptionsConfigurator<AlterationSerializationOptionConfigurator>(); |
| | 1 | 25 | | return services; |
| | | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Adds an alteration handler. |
| | | 30 | | /// </summary> |
| | | 31 | | public static IServiceCollection AddAlteration<T, THandler>(this IServiceCollection services) where T : IAlteration |
| | | 32 | | { |
| | 10 | 33 | | services.Configure<AlterationOptions>(options => options.AlterationTypes.Add(typeof(T))); |
| | 5 | 34 | | services.AddScoped<IAlterationHandler, THandler>(); |
| | 5 | 35 | | return services; |
| | | 36 | | } |
| | | 37 | | } |