using CShells.FastEndpoints.Features;
using CShells.Features;
using Elsa.Alterations.Core.Contracts;
using Elsa.Alterations.Core.Entities;
using Elsa.Alterations.Core.Extensions;
using Elsa.Alterations.Core.Models;
using Elsa.Alterations.Core.Stores;
using Elsa.Alterations.Extensions;
using Elsa.Alterations.Services;
using Elsa.Alterations.Workflows;
using Elsa.Extensions;
using Elsa.Workflows.Options;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using Elsa.Common.Serialization;
namespace Elsa.Alterations.ShellFeatures;
///
/// Adds the Elsa alterations services.
///
[ShellFeature(
DisplayName = "Alterations",
Description = "Provides workflow alteration capabilities for modifying running workflow instances",
DependsOn = ["ElsaFastEndpoints", "WorkflowRuntime"])]
[UsedImplicitly]
public class AlterationsFeature : IFastEndpointsShellFeature
{
///
/// Gets or sets the factory for the alteration plan store.
///
public Func AlterationPlanStoreFactory { get; set; } = sp => sp.GetRequiredService();
///
/// Gets or sets the factory for the alteration job store.
///
public Func AlterationJobStoreFactory { get; set; } = sp => sp.GetRequiredService();
///
/// Gets or sets the factory for the alteration job dispatcher.
///
public Func AlterationJobDispatcherFactory { get; set; } = sp => sp.GetRequiredService();
public void ConfigureServices(IServiceCollection services)
{
services.Configure(options =>
{
options.RegisterTypeAlias(typeof(AlterationPlanParams), nameof(AlterationPlanParams));
options.RegisterLegacySimpleAssemblyQualifiedName(typeof(AlterationPlanParams));
});
services.AddScoped();
services.AddAlterations();
services.AddAlterationsCore();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddMemoryStore();
services.AddMemoryStore();
services.AddScoped(AlterationPlanStoreFactory);
services.AddScoped(AlterationJobStoreFactory);
services.AddScoped(AlterationJobDispatcherFactory);
services.AddWorkflow();
}
}