Features API (#3081)

* Rename module and features

* Move Mediator, AspNetCore and Expressions to modules folder

* Update labels-widget.tsx
This commit is contained in:
Sipke Schoorstra 2022-05-27 12:36:39 +02:00 committed by GitHub
parent 105d060d71
commit a28d2eb63a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
147 changed files with 450 additions and 439 deletions

View file

@ -62,22 +62,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bundles", "bundles", "{F06B
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa", "src\bundles\Elsa\Elsa.csproj", "{FC5D2CE9-FFB0-478D-8D54-E4109D1FD202}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.AspNetCore", "src\common\Elsa.AspNetCore\Elsa.AspNetCore.csproj", "{C55F7AA0-0803-44CE-9AE4-BF697A1C0195}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Formatting", "src\common\Elsa.Formatting\Elsa.Formatting.csproj", "{60CEE728-3187-481B-B6EA-10D5284D8B55}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Jobs.Abstractions", "src\common\Elsa.Jobs.Abstractions\Elsa.Jobs.Abstractions.csproj", "{2782C593-98CD-4B80-B595-8BAE066DCBC3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Mediator", "src\common\Elsa.Mediator\Elsa.Mediator.csproj", "{ED3D8BFA-03AC-437F-AE25-1EDB58569099}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.ServiceBus.Abstractions", "src\common\Elsa.ServiceBus.Abstractions\Elsa.ServiceBus.Abstractions.csproj", "{448FCDE6-DE44-4E44-A1CC-B9AA51471121}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Liquid", "src\modules\Elsa.Liquid\Elsa.Liquid.csproj", "{8E5BD3D9-3529-48BC-B741-CFB7A69DB233}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.ProtoActor", "src\modules\Elsa.ProtoActor\Elsa.ProtoActor.csproj", "{B2049499-D384-46DF-8837-F1180107DD54}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Expressions", "src\common\Elsa.Expressions\Elsa.Expressions.csproj", "{042D22D7-35B6-4A72-9FBD-25EF1842B31E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Dsl", "src\modules\Elsa.Dsl\Elsa.Dsl.csproj", "{78DAB791-8595-4612-8E9E-2248AF5B1862}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Labels.EntityFrameworkCore.Sqlite", "src\modules\Elsa.Labels.EntityFrameworkCore.Sqlite\Elsa.Labels.EntityFrameworkCore.Sqlite.csproj", "{7610CB87-D50B-4E42-AE2C-0733A9A906B0}"
@ -104,10 +98,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Workflows.Persistence.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Workflows.Runtime", "src\modules\Elsa.Workflows.Runtime\Elsa.Workflows.Runtime.csproj", "{8A050229-DB79-4E0B-9AFF-7565E87F2954}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.ServiceConfiguration", "src\common\Elsa.ServiceConfiguration\Elsa.ServiceConfiguration.csproj", "{C237BA1A-3A7D-4AB2-BE09-2696F3C082A4}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Features", "src\common\Elsa.Features\Elsa.Features.csproj", "{C237BA1A-3A7D-4AB2-BE09-2696F3C082A4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.MemoryCache", "src\modules\Elsa.MemoryCache\Elsa.MemoryCache.csproj", "{2570418D-1674-4DAE-9A24-9146D522450C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.AspNetCore", "src\modules\Elsa.AspNetCore\Elsa.AspNetCore.csproj", "{2CFF3041-BB6A-45EA-9716-7BA531BA6479}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Expressions", "src\modules\Elsa.Expressions\Elsa.Expressions.csproj", "{80529478-A383-4FEA-B744-C71264969E9A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Mediator", "src\modules\Elsa.Mediator\Elsa.Mediator.csproj", "{40ED82D8-A7BB-4D37-9157-3176EDA3E119}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -190,10 +190,6 @@ Global
{FC5D2CE9-FFB0-478D-8D54-E4109D1FD202}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC5D2CE9-FFB0-478D-8D54-E4109D1FD202}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC5D2CE9-FFB0-478D-8D54-E4109D1FD202}.Release|Any CPU.Build.0 = Release|Any CPU
{C55F7AA0-0803-44CE-9AE4-BF697A1C0195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C55F7AA0-0803-44CE-9AE4-BF697A1C0195}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C55F7AA0-0803-44CE-9AE4-BF697A1C0195}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C55F7AA0-0803-44CE-9AE4-BF697A1C0195}.Release|Any CPU.Build.0 = Release|Any CPU
{60CEE728-3187-481B-B6EA-10D5284D8B55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{60CEE728-3187-481B-B6EA-10D5284D8B55}.Debug|Any CPU.Build.0 = Debug|Any CPU
{60CEE728-3187-481B-B6EA-10D5284D8B55}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -202,10 +198,6 @@ Global
{2782C593-98CD-4B80-B595-8BAE066DCBC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2782C593-98CD-4B80-B595-8BAE066DCBC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2782C593-98CD-4B80-B595-8BAE066DCBC3}.Release|Any CPU.Build.0 = Release|Any CPU
{ED3D8BFA-03AC-437F-AE25-1EDB58569099}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED3D8BFA-03AC-437F-AE25-1EDB58569099}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED3D8BFA-03AC-437F-AE25-1EDB58569099}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED3D8BFA-03AC-437F-AE25-1EDB58569099}.Release|Any CPU.Build.0 = Release|Any CPU
{448FCDE6-DE44-4E44-A1CC-B9AA51471121}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{448FCDE6-DE44-4E44-A1CC-B9AA51471121}.Debug|Any CPU.Build.0 = Debug|Any CPU
{448FCDE6-DE44-4E44-A1CC-B9AA51471121}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -218,10 +210,6 @@ Global
{B2049499-D384-46DF-8837-F1180107DD54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2049499-D384-46DF-8837-F1180107DD54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2049499-D384-46DF-8837-F1180107DD54}.Release|Any CPU.Build.0 = Release|Any CPU
{042D22D7-35B6-4A72-9FBD-25EF1842B31E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{042D22D7-35B6-4A72-9FBD-25EF1842B31E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{042D22D7-35B6-4A72-9FBD-25EF1842B31E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{042D22D7-35B6-4A72-9FBD-25EF1842B31E}.Release|Any CPU.Build.0 = Release|Any CPU
{78DAB791-8595-4612-8E9E-2248AF5B1862}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78DAB791-8595-4612-8E9E-2248AF5B1862}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78DAB791-8595-4612-8E9E-2248AF5B1862}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -282,6 +270,18 @@ Global
{2570418D-1674-4DAE-9A24-9146D522450C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2570418D-1674-4DAE-9A24-9146D522450C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2570418D-1674-4DAE-9A24-9146D522450C}.Release|Any CPU.Build.0 = Release|Any CPU
{2CFF3041-BB6A-45EA-9716-7BA531BA6479}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CFF3041-BB6A-45EA-9716-7BA531BA6479}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CFF3041-BB6A-45EA-9716-7BA531BA6479}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CFF3041-BB6A-45EA-9716-7BA531BA6479}.Release|Any CPU.Build.0 = Release|Any CPU
{80529478-A383-4FEA-B744-C71264969E9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80529478-A383-4FEA-B744-C71264969E9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80529478-A383-4FEA-B744-C71264969E9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80529478-A383-4FEA-B744-C71264969E9A}.Release|Any CPU.Build.0 = Release|Any CPU
{40ED82D8-A7BB-4D37-9157-3176EDA3E119}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{40ED82D8-A7BB-4D37-9157-3176EDA3E119}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40ED82D8-A7BB-4D37-9157-3176EDA3E119}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40ED82D8-A7BB-4D37-9157-3176EDA3E119}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{155227F0-A33B-40AA-A4B4-06F813EB921B} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
@ -298,12 +298,9 @@ Global
{6B80C8AC-E9E7-43FD-B514-C0D801D15792} = {90031D64-CA0F-46D0-9AF4-8DC023A5FFCD}
{177F4FF3-4618-4CB1-BA93-8B024BC64CD8} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
{F06B9573-DF68-4606-866C-A7546A10A05A} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
{C55F7AA0-0803-44CE-9AE4-BF697A1C0195} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
{60CEE728-3187-481B-B6EA-10D5284D8B55} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
{2782C593-98CD-4B80-B595-8BAE066DCBC3} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
{ED3D8BFA-03AC-437F-AE25-1EDB58569099} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
{448FCDE6-DE44-4E44-A1CC-B9AA51471121} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
{042D22D7-35B6-4A72-9FBD-25EF1842B31E} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
{B2049499-D384-46DF-8837-F1180107DD54} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{FC5D2CE9-FFB0-478D-8D54-E4109D1FD202} = {F06B9573-DF68-4606-866C-A7546A10A05A}
{E31F8955-B221-48AA-B301-6EE317D6F5B1} = {F06B9573-DF68-4606-866C-A7546A10A05A}
@ -332,5 +329,8 @@ Global
{8A050229-DB79-4E0B-9AFF-7565E87F2954} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{C237BA1A-3A7D-4AB2-BE09-2696F3C082A4} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
{2570418D-1674-4DAE-9A24-9146D522450C} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{2CFF3041-BB6A-45EA-9716-7BA531BA6479} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{80529478-A383-4FEA-B744-C71264969E9A} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{40ED82D8-A7BB-4D37-9157-3176EDA3E119} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
EndGlobalSection
EndGlobal

View file

@ -9,7 +9,7 @@
<ItemGroup>
<ProjectReference Include="..\..\bundles\Elsa\Elsa.csproj" />
<ProjectReference Include="..\..\common\Elsa.AspNetCore\Elsa.AspNetCore.csproj" />
<ProjectReference Include="..\..\modules\Elsa.AspNetCore\Elsa.AspNetCore.csproj" />
<ProjectReference Include="..\..\common\Elsa.Jobs.Abstractions\Elsa.Jobs.Abstractions.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Hangfire\Elsa.Hangfire.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Http\Elsa.Http.csproj" />

View file

@ -9,7 +9,7 @@
<ItemGroup>
<ProjectReference Include="..\..\modules\Elsa.ProtoActor\Elsa.ProtoActor.csproj" />
<ProjectReference Include="..\Elsa\Elsa.csproj" />
<ProjectReference Include="..\..\common\Elsa.AspNetCore\Elsa.AspNetCore.csproj" />
<ProjectReference Include="..\..\modules\Elsa.AspNetCore\Elsa.AspNetCore.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Hangfire\Elsa.Hangfire.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Http\Elsa.Http.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Labels.EntityFrameworkCore.Sqlite\Elsa.Labels.EntityFrameworkCore.Sqlite.csproj" />

View file

@ -46,7 +46,7 @@ services
.AddActivity<Switch>()
.AddActivity<RunJavaScript>()
)
.UsePersistence(p => p.UseEntityFrameworkCore(ef => ef.UseSqlite()))
.UseWorkflowPersistence(p => p.UseEntityFrameworkCore(ef => ef.UseSqlite()))
.UseJavaScript()
.UseLiquid()
.UseLabels(labels => labels.UseEntityFrameworkCore(ef => ef.UseSqlite()))

View file

@ -1,22 +0,0 @@
using Elsa.Mediator.Configuration;
using Elsa.ServiceConfiguration.Abstractions;
using Elsa.ServiceConfiguration.Attributes;
using Elsa.ServiceConfiguration.Services;
using Elsa.Workflows.Core.Configuration;
using Elsa.Workflows.Management.Configuration;
using Elsa.Workflows.Persistence.Configuration;
using Elsa.Workflows.Runtime.Configuration;
namespace Elsa.Configuration;
[Dependency(typeof(MediatorConfigurator))]
[Dependency(typeof(WorkflowsConfigurator))]
[Dependency(typeof(WorkflowPersistenceConfigurator))]
[Dependency(typeof(WorkflowRuntimeConfigurator))]
[Dependency(typeof(WorkflowManagementConfigurator))]
public class ElsaConfigurator : ConfiguratorBase
{
public ElsaConfigurator(IServiceConfiguration serviceConfiguration) : base(serviceConfiguration)
{
}
}

View file

@ -14,7 +14,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\common\Elsa.Mediator\Elsa.Mediator.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Mediator\Elsa.Mediator.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Workflows.Core\Elsa.Workflows.Core.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Workflows.Management\Elsa.Workflows.Management.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Workflows.Runtime\Elsa.Workflows.Runtime.csproj" />

View file

@ -1,14 +1,14 @@
using System;
using Elsa.Configuration;
using Elsa.ServiceConfiguration.Extensions;
using Elsa.ServiceConfiguration.Services;
using Elsa.Features;
using Elsa.Features.Extensions;
using Elsa.Features.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Extensions;
public static class DependencyInjectionExtensions
{
public static IServiceCollection AddElsa(this IServiceCollection services, Action<IServiceConfiguration>? configure = default)
public static IServiceCollection AddElsa(this IServiceCollection services, Action<IModule>? configure = default)
{
var serviceConfiguration = services.ConfigureElsa();
configure?.Invoke(serviceConfiguration);
@ -16,11 +16,11 @@ public static class DependencyInjectionExtensions
return services;
}
public static IServiceConfiguration ConfigureElsa(this IServiceCollection services)
public static IModule ConfigureElsa(this IServiceCollection services)
{
var serviceConfiguration = services.ConfigureServices();
serviceConfiguration.Configure<ElsaConfigurator>();
var module = services.CreateModule();
module.Configure<ElsaFeature>();
return serviceConfiguration;
return module;
}
}

View file

@ -0,0 +1,22 @@
using Elsa.Features.Abstractions;
using Elsa.Features.Attributes;
using Elsa.Features.Services;
using Elsa.Mediator.Features;
using Elsa.Workflows.Core.Features;
using Elsa.Workflows.Management.Features;
using Elsa.Workflows.Persistence.Features;
using Elsa.Workflows.Runtime.Features;
namespace Elsa.Features;
[DependsOn(typeof(MediatorFeature))]
[DependsOn(typeof(WorkflowsFeature))]
[DependsOn(typeof(WorkflowPersistenceFeature))]
[DependsOn(typeof(WorkflowRuntimeFeature))]
[DependsOn(typeof(WorkflowManagementFeature))]
public class ElsaFeature : FeatureBase
{
public ElsaFeature(IModule module) : base(module)
{
}
}

View file

@ -1,18 +0,0 @@
using Elsa.AspNetCore.Conventions;
using Elsa.ServiceConfiguration.Abstractions;
using Elsa.ServiceConfiguration.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.AspNetCore.Configuration;
public class MvcConfigurator : ConfiguratorBase
{
public MvcConfigurator(IServiceConfiguration serviceConfiguration) : base(serviceConfiguration)
{
}
public override void Configure()
{
Services.AddMvc(mvc => mvc.Conventions.Add(new ApiEndpointAttributeConvention()));
}
}

View file

@ -1,13 +0,0 @@
using Elsa.AspNetCore.Configuration;
using Elsa.ServiceConfiguration.Services;
namespace Elsa.AspNetCore.Extensions;
public static class DependencyInjectionExtensions
{
public static IServiceConfiguration UseMvc(this IServiceConfiguration configuration, Action<MvcConfigurator>? configure = default)
{
configuration.Configure(configure);
return configuration;
}
}

View file

@ -0,0 +1,27 @@
using Elsa.Features.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Features.Abstractions;
public abstract class FeatureBase : IFeature
{
protected FeatureBase(IModule module)
{
Module = module;
}
public IModule Module { get; }
public IServiceCollection Services => Module.Services;
public virtual void Configure()
{
}
public virtual void ConfigureHostedServices()
{
}
public virtual void Apply()
{
}
}

View file

@ -1,9 +1,9 @@
namespace Elsa.ServiceConfiguration.Attributes;
namespace Elsa.Features.Attributes;
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class DependencyAttribute : Attribute
public class DependsOn : Attribute
{
public DependencyAttribute(Type type)
public DependsOn(Type type)
{
Type = type;
}

View file

@ -0,0 +1,10 @@
using Elsa.Features.Implementations;
using Elsa.Features.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Features.Extensions;
public static class DependencyInjectionExtensions
{
public static IModule CreateModule(this IServiceCollection services) => new Module(services);
}

View file

@ -1,29 +1,29 @@
using System.Reflection;
using Elsa.ServiceConfiguration.Attributes;
using Elsa.ServiceConfiguration.Services;
using Elsa.Features.Attributes;
using Elsa.Features.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
namespace Elsa.ServiceConfiguration.Implementations;
namespace Elsa.Features.Implementations;
public class ServiceConfiguration : IServiceConfiguration
public class Module : IModule
{
private record HostedServiceDescriptor(int Order, Type HostedServiceType);
private readonly ISet<IConfigurator> _configurators = new HashSet<IConfigurator>();
private readonly ISet<IFeature> _configurators = new HashSet<IFeature>();
private readonly ICollection<HostedServiceDescriptor> _hostedServiceDescriptors = new List<HostedServiceDescriptor>();
public ServiceConfiguration(IServiceCollection services)
public Module(IServiceCollection services)
{
Services = services;
}
public IServiceCollection Services { get; }
public T Configure<T>(Action<T>? configure = default) where T : class, IConfigurator => Configure(serviceConfiguration => (T)Activator.CreateInstance(typeof(T), serviceConfiguration)!, configure);
public T Configure<T>(Action<T>? configure = default) where T : class, IFeature => Configure(serviceConfiguration => (T)Activator.CreateInstance(typeof(T), serviceConfiguration)!, configure);
public T Configure<T>(Func<IServiceConfiguration, T> factory, Action<T>? configure = default) where T : class, IConfigurator
public T Configure<T>(Func<IModule, T> factory, Action<T>? configure = default) where T : class, IFeature
{
if (_configurators.FirstOrDefault(x => x is T) is not T configurator)
{
@ -35,7 +35,7 @@ public class ServiceConfiguration : IServiceConfiguration
return configurator;
}
public IServiceConfiguration ConfigureHostedService<T>(int priority = 0)
public IModule ConfigureHostedService<T>(int priority = 0)
{
_hostedServiceDescriptors.Add(new HostedServiceDescriptor(priority, typeof(T)));
return this;
@ -68,9 +68,9 @@ public class ServiceConfiguration : IServiceConfiguration
ResolveDependencies(configurator, resolvedDependencyTypes);
}
private void ResolveDependencies(IConfigurator configurator, ISet<Type> resolvedDependencyTypes)
private void ResolveDependencies(IFeature feature, ISet<Type> resolvedDependencyTypes)
{
var dependencyTypes = configurator.GetType().GetCustomAttributes<DependencyAttribute>().Select(x => x.Type).ToHashSet();
var dependencyTypes = feature.GetType().GetCustomAttributes<DependsOn>().Select(x => x.Type).ToHashSet();
dependencyTypes = dependencyTypes.Except(resolvedDependencyTypes).ToHashSet();
foreach (var type in dependencyTypes)
@ -81,14 +81,14 @@ public class ServiceConfiguration : IServiceConfiguration
}
}
private IConfigurator AddConfigurator(Type type)
private IFeature AddConfigurator(Type type)
{
var configurator = _configurators.FirstOrDefault(x => x.GetType() == type);
if (configurator != null)
return configurator;
configurator = (IConfigurator)Activator.CreateInstance(type, this)!;
configurator = (IFeature)Activator.CreateInstance(type, this)!;
_configurators.Add(configurator);
return configurator;
}

View file

@ -0,0 +1,10 @@
namespace Elsa.Features.Services;
public interface IFeature
{
IModule Module { get; }
void Configure();
void ConfigureHostedServices();
void Apply();
}

View file

@ -0,0 +1,12 @@
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Features.Services;
public interface IModule
{
IServiceCollection Services { get; }
T Configure<T>(Action<T>? configure = default) where T : class, IFeature;
T Configure<T>(Func<IModule, T> factory, Action<T>? configure = default) where T : class, IFeature;
IModule ConfigureHostedService<T>(int priority = 0);
void Apply();
}

View file

@ -1,17 +0,0 @@
using Elsa.Mediator.Extensions;
using Elsa.ServiceConfiguration.Abstractions;
using Elsa.ServiceConfiguration.Services;
namespace Elsa.Mediator.Configuration;
public class MediatorConfigurator : ConfiguratorBase
{
public MediatorConfigurator(IServiceConfiguration serviceConfiguration) : base(serviceConfiguration)
{
}
public override void Apply()
{
Services.AddMediator();
}
}

View file

@ -2,16 +2,16 @@ using Elsa.Persistence.Common.Entities;
using Elsa.Persistence.EntityFrameworkCore.Common.HostedServices;
using Elsa.Persistence.EntityFrameworkCore.Common.Implementations;
using Elsa.Persistence.EntityFrameworkCore.Common.Services;
using Elsa.ServiceConfiguration.Abstractions;
using Elsa.ServiceConfiguration.Services;
using Elsa.Features.Abstractions;
using Elsa.Features.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Persistence.EntityFrameworkCore.Common.Abstractions;
public abstract class EFCorePersistenceConfigurator<TDbContext> : ConfiguratorBase where TDbContext : DbContext
public abstract class EFCorePersistenceFeature<TDbContext> : FeatureBase where TDbContext : DbContext
{
protected EFCorePersistenceConfigurator(IServiceConfiguration serviceConfiguration) : base(serviceConfiguration)
protected EFCorePersistenceFeature(IModule module) : base(module)
{
}
@ -20,19 +20,19 @@ public abstract class EFCorePersistenceConfigurator<TDbContext> : ConfiguratorBa
public ServiceLifetime DbContextFactoryLifetime { get; set; } = ServiceLifetime.Singleton;
public Action<IServiceProvider, DbContextOptionsBuilder> DbContextOptionsBuilderAction = (_, _) => { };
public EFCorePersistenceConfigurator<TDbContext> WithContextPooling(bool enabled = true)
public EFCorePersistenceFeature<TDbContext> WithContextPooling(bool enabled = true)
{
ContextPoolingIsEnabled = enabled;
return this;
}
public EFCorePersistenceConfigurator<TDbContext> AutoRunMigrations(bool enabled = true)
public EFCorePersistenceFeature<TDbContext> AutoRunMigrations(bool enabled = true)
{
AutoRunMigrationsIsEnabled = enabled;
return this;
}
public EFCorePersistenceConfigurator<TDbContext> ConfigureDbContextOptions(Action<IServiceProvider, DbContextOptionsBuilder> configure)
public EFCorePersistenceFeature<TDbContext> ConfigureDbContextOptions(Action<IServiceProvider, DbContextOptionsBuilder> configure)
{
DbContextOptionsBuilderAction = configure;
return this;
@ -41,7 +41,7 @@ public abstract class EFCorePersistenceConfigurator<TDbContext> : ConfiguratorBa
public override void ConfigureHostedServices()
{
if (AutoRunMigrationsIsEnabled)
ServiceConfiguration.ConfigureHostedService<RunMigrations<TDbContext>>(-1); // Migrations need to run before other hosted services that depend on DB access.
Module.ConfigureHostedService<RunMigrations<TDbContext>>(-1); // Migrations need to run before other hosted services that depend on DB access.
}
public override void Apply()

View file

@ -24,7 +24,7 @@
<ItemGroup>
<ProjectReference Include="..\Elsa.Persistence.Abstractions\Elsa.Persistence.Abstractions.csproj" />
<ProjectReference Include="..\Elsa.ServiceConfiguration\Elsa.ServiceConfiguration.csproj" />
<ProjectReference Include="..\Elsa.Features\Elsa.Features.csproj" />
</ItemGroup>
</Project>

View file

@ -1,27 +0,0 @@
using Elsa.ServiceConfiguration.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.ServiceConfiguration.Abstractions;
public abstract class ConfiguratorBase : IConfigurator
{
protected ConfiguratorBase(IServiceConfiguration serviceConfiguration)
{
ServiceConfiguration = serviceConfiguration;
}
public IServiceConfiguration ServiceConfiguration { get; }
public IServiceCollection Services => ServiceConfiguration.Services;
public virtual void Configure()
{
}
public virtual void ConfigureHostedServices()
{
}
public virtual void Apply()
{
}
}

View file

@ -1,10 +0,0 @@
using Elsa.ServiceConfiguration.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.ServiceConfiguration.Extensions;
public static class DependencyInjectionExtensions
{
public static IServiceConfiguration ConfigureServices(this IServiceCollection services) =>
new ServiceConfiguration.Implementations.ServiceConfiguration(services);
}

View file

@ -1,10 +0,0 @@
namespace Elsa.ServiceConfiguration.Services;
public interface IConfigurator
{
IServiceConfiguration ServiceConfiguration { get; }
void Configure();
void ConfigureHostedServices();
void Apply();
}

View file

@ -1,12 +0,0 @@
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.ServiceConfiguration.Services;
public interface IServiceConfiguration
{
IServiceCollection Services { get; }
T Configure<T>(Action<T>? configure = default) where T : class, IConfigurator;
T Configure<T>(Func<IServiceConfiguration, T> factory, Action<T>? configure = default) where T : class, IConfigurator;
IServiceConfiguration ConfigureHostedService<T>(int priority = 0);
void Apply();
}

View file

@ -27,7 +27,6 @@ export class LabelsWidget {
private refreshWorkflowProperties: () => void;
private definitionVersionId: string;
constructor() {
this.eventBus = Container.get(EventBus);
this.workflowDefinitionManager = Container.get(WorkflowDefinitionManager);
@ -97,6 +96,13 @@ export class LabelsWidget {
private onWorkflowDefinitionImported = async (e: WorkflowDefinitionImportedArgs) => {
const workflowDefinition = e.workflowDefinition;
if (isNullOrWhitespace(workflowDefinition.id)) {
this.definitionVersionId = null;
this.assignedLabelIds = [];
return;
}
const assignedLabelIds = await this.workflowDefinitionLabelsApi.get(workflowDefinition.id);
this.assignedLabelIds = assignedLabelIds;
this.definitionVersionId = workflowDefinition.id;

View file

@ -13,7 +13,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Elsa.ServiceConfiguration\Elsa.ServiceConfiguration.csproj" />
<ProjectReference Include="..\..\common\Elsa.Features\Elsa.Features.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,13 @@
using Elsa.AspNetCore.Features;
using Elsa.Features.Services;
namespace Elsa.AspNetCore.Extensions;
public static class DependencyInjectionExtensions
{
public static IModule UseMvc(this IModule configuration, Action<MvcFeature>? configure = default)
{
configuration.Configure(configure);
return configuration;
}
}

View file

@ -0,0 +1,18 @@
using Elsa.AspNetCore.Conventions;
using Elsa.Features.Abstractions;
using Elsa.Features.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.AspNetCore.Features;
public class MvcFeature : FeatureBase
{
public MvcFeature(IModule module) : base(module)
{
}
public override void Configure()
{
Services.AddMvc(mvc => mvc.Conventions.Add(new ApiEndpointAttributeConvention()));
}
}

View file

@ -16,7 +16,7 @@
<ItemGroup>
<ProjectReference Include="..\..\common\Elsa.Formatting\Elsa.Formatting.csproj" />
<ProjectReference Include="..\..\common\Elsa.Mediator\Elsa.Mediator.csproj" />
<ProjectReference Include="..\Elsa.Mediator\Elsa.Mediator.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Core\Elsa.Workflows.Core.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Persistence\Elsa.Workflows.Persistence.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Runtime\Elsa.Workflows.Runtime.csproj" />

View file

@ -1,27 +0,0 @@
using Elsa.Dsl.Implementations;
using Elsa.Dsl.Services;
using Elsa.Expressions.Configuration;
using Elsa.JavaScript.Configuration;
using Elsa.ServiceConfiguration.Abstractions;
using Elsa.ServiceConfiguration.Attributes;
using Elsa.ServiceConfiguration.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Dsl.Configuration;
[Dependency(typeof(JavaScriptConfigurator))]
[Dependency(typeof(ExpressionsConfigurator))]
public class DslConfigurator : ConfiguratorBase
{
public DslConfigurator(IServiceConfiguration serviceConfiguration) : base(serviceConfiguration)
{
}
public override void Configure()
{
Services
.AddSingleton<IDslEngine, DslEngine>()
.AddSingleton<ITypeSystem, TypeSystem>()
.AddSingleton<IFunctionActivityRegistry, FunctionActivityRegistry>();
}
}

View file

@ -1,12 +1,12 @@
using System;
using Elsa.Dsl.Configuration;
using Elsa.ServiceConfiguration.Services;
using Elsa.Dsl.Features;
using Elsa.Features.Services;
namespace Elsa.Dsl.Extensions;
public static class DependencyInjectionExtensions
{
public static IServiceConfiguration UseDsl(this IServiceConfiguration configuration, Action<DslConfigurator>? configure = default)
public static IModule UseDsl(this IModule configuration, Action<DslFeature>? configure = default)
{
configuration.Configure(configure);
return configuration;

View file

@ -0,0 +1,27 @@
using Elsa.Dsl.Implementations;
using Elsa.Dsl.Services;
using Elsa.Expressions.Features;
using Elsa.Features.Abstractions;
using Elsa.Features.Attributes;
using Elsa.Features.Services;
using Elsa.JavaScript.Features;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Dsl.Features;
[DependsOn(typeof(JavaScriptFeature))]
[DependsOn(typeof(ExpressionsFeature))]
public class DslFeature : FeatureBase
{
public DslFeature(IModule module) : base(module)
{
}
public override void Configure()
{
Services
.AddSingleton<IDslEngine, DslEngine>()
.AddSingleton<ITypeSystem, TypeSystem>()
.AddSingleton<IFunctionActivityRegistry, FunctionActivityRegistry>();
}
}

View file

@ -13,7 +13,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Elsa.ServiceConfiguration\Elsa.ServiceConfiguration.csproj" />
<ProjectReference Include="..\..\common\Elsa.Features\Elsa.Features.csproj" />
</ItemGroup>
</Project>

View file

@ -1,7 +1,7 @@
using Elsa.Expressions.Configuration;
using Elsa.Expressions.Features;
using Elsa.Expressions.Options;
using Elsa.Expressions.Services;
using Elsa.ServiceConfiguration.Services;
using Elsa.Features.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
@ -9,7 +9,7 @@ namespace Elsa.Expressions.Extensions;
public static class DependencyInjectionExtensions
{
public static IServiceConfiguration UseExpressions(this IServiceConfiguration configuration, Action<ExpressionsConfigurator>? configure = default)
public static IModule UseExpressions(this IModule configuration, Action<ExpressionsFeature>? configure = default)
{
configuration.Configure(configure);
return configuration;

View file

@ -1,14 +1,14 @@
using Elsa.Expressions.Implementations;
using Elsa.Expressions.Services;
using Elsa.ServiceConfiguration.Abstractions;
using Elsa.ServiceConfiguration.Services;
using Elsa.Features.Abstractions;
using Elsa.Features.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Expressions.Configuration;
namespace Elsa.Expressions.Features;
public class ExpressionsConfigurator : ConfiguratorBase
public class ExpressionsFeature : FeatureBase
{
public ExpressionsConfigurator(IServiceConfiguration serviceConfiguration) : base(serviceConfiguration)
public ExpressionsFeature(IModule module) : base(module)
{
}

View file

@ -1,15 +1,15 @@
using System;
using Elsa.Http.Configuration;
using Elsa.ServiceConfiguration.Services;
using Elsa.Features.Services;
using Elsa.Http.Features;
// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.DependencyInjection;
public static class DependencyInjectionExtensions
{
public static IServiceConfiguration UseHttp(this IServiceConfiguration configuration, Action<HttpConfigurator>? configure = default)
public static IModule UseHttp(this IModule module, Action<HttpFeature>? configure = default)
{
configuration.Configure(configure);
return configuration;
module.Configure(configure);
return module;
}
}

View file

@ -1,18 +1,18 @@
using System;
using Elsa.Features.Abstractions;
using Elsa.Features.Services;
using Elsa.Http.Handlers;
using Elsa.Http.Implementations;
using Elsa.Http.Options;
using Elsa.Http.Services;
using Elsa.Mediator.Extensions;
using Elsa.ServiceConfiguration.Abstractions;
using Elsa.ServiceConfiguration.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Http.Configuration;
namespace Elsa.Http.Features;
public class HttpConfigurator : ConfiguratorBase
public class HttpFeature : FeatureBase
{
public HttpConfigurator(IServiceConfiguration serviceConfiguration) : base(serviceConfiguration)
public HttpFeature(IModule module) : base(module)
{
}
@ -20,19 +20,19 @@ public class HttpConfigurator : ConfiguratorBase
public Func<IServiceProvider, IHttpEndpointAuthorizationHandler> HttpEndpointAuthorizationHandlerFactory { get; set; } = ActivatorUtilities.GetServiceOrCreateInstance<AllowAnonymousHttpEndpointAuthorizationHandler>;
public Func<IServiceProvider, IHttpEndpointWorkflowFaultHandler> HttpEndpointWorkflowFaultHandlerFactory { get; set; } = ActivatorUtilities.GetServiceOrCreateInstance<DefaultHttpEndpointWorkflowFaultHandler>;
public HttpConfigurator WithBasePath(string value)
public HttpFeature WithBasePath(string value)
{
BasePath = value;
return this;
}
public HttpConfigurator WithAuthorizationHandlerFactory(Func<IServiceProvider, IHttpEndpointAuthorizationHandler> value)
public HttpFeature WithAuthorizationHandlerFactory(Func<IServiceProvider, IHttpEndpointAuthorizationHandler> value)
{
HttpEndpointAuthorizationHandlerFactory = value;
return this;
}
public HttpConfigurator WithWorkflowFaultHandlerFactory(Func<IServiceProvider, IHttpEndpointWorkflowFaultHandler> value)
public HttpFeature WithWorkflowFaultHandlerFactory(Func<IServiceProvider, IHttpEndpointWorkflowFaultHandler> value)
{
HttpEndpointWorkflowFaultHandlerFactory = value;
return this;

View file

@ -7,8 +7,8 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\common\Elsa.Expressions\Elsa.Expressions.csproj" />
<ProjectReference Include="..\..\common\Elsa.Mediator\Elsa.Mediator.csproj" />
<ProjectReference Include="..\Elsa.Expressions\Elsa.Expressions.csproj" />
<ProjectReference Include="..\Elsa.Mediator\Elsa.Mediator.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Core\Elsa.Workflows.Core.csproj" />
</ItemGroup>

View file

@ -1,13 +1,13 @@
using Elsa.JavaScript.Configuration;
using Elsa.ServiceConfiguration.Services;
using Elsa.Features.Services;
using Elsa.JavaScript.Features;
namespace Elsa.JavaScript.Extensions;
public static class DependencyInjectionExtensions
{
public static IServiceConfiguration UseJavaScript(this IServiceConfiguration serviceConfiguration, Action<JavaScriptConfigurator>? configure = default)
public static IModule UseJavaScript(this IModule module, Action<JavaScriptFeature>? configure = default)
{
serviceConfiguration.Configure(configure);
return serviceConfiguration;
module.Configure(configure);
return module;
}
}

View file

@ -1,25 +1,25 @@
using Elsa.Expressions.Configuration;
using Elsa.Expressions.Extensions;
using Elsa.Expressions.Features;
using Elsa.Expressions.Services;
using Elsa.Features.Abstractions;
using Elsa.Features.Attributes;
using Elsa.Features.Services;
using Elsa.JavaScript.Expressions;
using Elsa.JavaScript.Handlers;
using Elsa.JavaScript.Implementations;
using Elsa.JavaScript.Providers;
using Elsa.JavaScript.Services;
using Elsa.Mediator.Configuration;
using Elsa.Mediator.Extensions;
using Elsa.ServiceConfiguration.Abstractions;
using Elsa.ServiceConfiguration.Attributes;
using Elsa.ServiceConfiguration.Services;
using Elsa.Mediator.Features;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.JavaScript.Configuration;
namespace Elsa.JavaScript.Features;
[Dependency(typeof(MediatorConfigurator))]
[Dependency(typeof(ExpressionsConfigurator))]
public class JavaScriptConfigurator : ConfiguratorBase
[DependsOn(typeof(MediatorFeature))]
[DependsOn(typeof(ExpressionsFeature))]
public class JavaScriptFeature : FeatureBase
{
public JavaScriptConfigurator(IServiceConfiguration serviceConfiguration) : base(serviceConfiguration)
public JavaScriptFeature(IModule module) : base(module)
{
}

View file

@ -1,13 +1,14 @@
using Elsa.Labels.EntityFrameworkCore.Configuration;
using Elsa.Labels.EntityFrameworkCore.Features;
namespace Elsa.Labels.EntityFrameworkCore.Sqlite
{
public static class DependencyInjectionExtensions
{
public static EFCoreLabelPersistenceConfigurator UseSqlite(this EFCoreLabelPersistenceConfigurator configurator, string connectionString = "Data Source=elsa.sqlite.db;Cache=Shared;")
public static EFCoreLabelPersistenceFeature UseSqlite(this EFCoreLabelPersistenceFeature feature, string connectionString = "Data Source=elsa.sqlite.db;Cache=Shared;")
{
configurator.ConfigureDbContextOptions((_, db) => db.UseSqlite(connectionString));
return configurator;
feature.ConfigureDbContextOptions((_, db) => db.UseSqlite(connectionString));
return feature;
}
}
}

View file

@ -1,13 +1,13 @@
using Elsa.Labels.Configuration;
using Elsa.Labels.EntityFrameworkCore.Configuration;
using Elsa.Labels.EntityFrameworkCore.Features;
using Elsa.Labels.Features;
namespace Elsa.Labels.EntityFrameworkCore.Extensions;
public static class DependencyInjectionExtensions
{
public static LabelsConfigurator UseEntityFrameworkCore(this LabelsConfigurator configurator, Action<EFCoreLabelPersistenceConfigurator> configure)
public static LabelsFeature UseEntityFrameworkCore(this LabelsFeature feature, Action<EFCoreLabelPersistenceFeature> configure)
{
configurator.ServiceConfiguration.Configure(configure);
return configurator;
feature.Module.Configure(configure);
return feature;
}
}

View file

@ -1,24 +1,24 @@
using Elsa.Labels.Configuration;
using Elsa.Features.Attributes;
using Elsa.Features.Services;
using Elsa.Labels.Entities;
using Elsa.Labels.EntityFrameworkCore.Implementations;
using Elsa.Labels.Extensions;
using Elsa.Labels.Features;
using Elsa.Persistence.EntityFrameworkCore.Common.Abstractions;
using Elsa.ServiceConfiguration.Attributes;
using Elsa.ServiceConfiguration.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Labels.EntityFrameworkCore.Configuration;
namespace Elsa.Labels.EntityFrameworkCore.Features;
[Dependency(typeof(LabelsConfigurator))]
public class EFCoreLabelPersistenceConfigurator : EFCorePersistenceConfigurator<LabelsDbContext>
[DependsOn(typeof(LabelsFeature))]
public class EFCoreLabelPersistenceFeature : EFCorePersistenceFeature<LabelsDbContext>
{
public EFCoreLabelPersistenceConfigurator(IServiceConfiguration serviceConfiguration) : base(serviceConfiguration)
public EFCoreLabelPersistenceFeature(IModule module) : base(module)
{
}
public override void Configure()
{
ServiceConfiguration.UseLabels(labels => labels
Module.UseLabels(labels => labels
.WithLabelStore(sp => sp.GetRequiredService<EFCoreLabelStore>())
.WithWorkflowDefinitionLabelStore(sp => sp.GetRequiredService<EFCoreWorkflowDefinitionLabelStore>())
);

View file

@ -15,8 +15,8 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\common\Elsa.AspNetCore\Elsa.AspNetCore.csproj" />
<ProjectReference Include="..\..\common\Elsa.Mediator\Elsa.Mediator.csproj" />
<ProjectReference Include="..\Elsa.AspNetCore\Elsa.AspNetCore.csproj" />
<ProjectReference Include="..\Elsa.Mediator\Elsa.Mediator.csproj" />
<ProjectReference Include="..\..\common\Elsa.Persistence.Abstractions\Elsa.Persistence.Abstractions.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Core\Elsa.Workflows.Core.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Management\Elsa.Workflows.Management.csproj" />

View file

@ -1,11 +1,11 @@
using Elsa.Labels.Configuration;
using Elsa.ServiceConfiguration.Services;
using Elsa.Features.Services;
using Elsa.Labels.Features;
namespace Elsa.Labels.Extensions;
public static class DependencyInjectionExtensions
{
public static IServiceConfiguration UseLabels(this IServiceConfiguration configuration, Action<LabelsConfigurator>? configure = default)
public static IModule UseLabels(this IModule configuration, Action<LabelsFeature>? configure = default)
{
configuration.Configure(configure);
return configuration;

View file

@ -1,33 +1,33 @@
using Elsa.Features.Abstractions;
using Elsa.Features.Attributes;
using Elsa.Features.Services;
using Elsa.Labels.Entities;
using Elsa.Labels.Implementations;
using Elsa.Labels.Services;
using Elsa.Mediator.Configuration;
using Elsa.Mediator.Extensions;
using Elsa.Mediator.Features;
using Elsa.Persistence.Common.Extensions;
using Elsa.ServiceConfiguration.Abstractions;
using Elsa.ServiceConfiguration.Attributes;
using Elsa.ServiceConfiguration.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Labels.Configuration;
namespace Elsa.Labels.Features;
[Dependency(typeof(MediatorConfigurator))]
public class LabelsConfigurator : ConfiguratorBase
[DependsOn(typeof(MediatorFeature))]
public class LabelsFeature : FeatureBase
{
public LabelsConfigurator(IServiceConfiguration serviceConfiguration) : base(serviceConfiguration)
public LabelsFeature(IModule module) : base(module)
{
}
public Func<IServiceProvider, ILabelStore> LabelStore { get; set; } = sp => sp.GetRequiredService<InMemoryLabelStore>();
public Func<IServiceProvider, IWorkflowDefinitionLabelStore> WorkflowDefinitionLabelStore { get; set; } = sp => sp.GetRequiredService<InMemoryWorkflowDefinitionLabelStore>();
public LabelsConfigurator WithLabelStore(Func<IServiceProvider, ILabelStore> factory)
public LabelsFeature WithLabelStore(Func<IServiceProvider, ILabelStore> factory)
{
LabelStore = factory;
return this;
}
public LabelsConfigurator WithWorkflowDefinitionLabelStore(Func<IServiceProvider, IWorkflowDefinitionLabelStore> factory)
public LabelsFeature WithWorkflowDefinitionLabelStore(Func<IServiceProvider, IWorkflowDefinitionLabelStore> factory)
{
WorkflowDefinitionLabelStore = factory;
return this;

View file

@ -13,8 +13,8 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\common\Elsa.Expressions\Elsa.Expressions.csproj" />
<ProjectReference Include="..\..\common\Elsa.Mediator\Elsa.Mediator.csproj" />
<ProjectReference Include="..\Elsa.Expressions\Elsa.Expressions.csproj" />
<ProjectReference Include="..\Elsa.Mediator\Elsa.Mediator.csproj" />
<ProjectReference Include="..\Elsa.MemoryCache\Elsa.MemoryCache.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Core\Elsa.Workflows.Core.csproj" />
</ItemGroup>

View file

@ -1,18 +1,18 @@
using Elsa.Liquid.Configuration;
using Elsa.Features.Services;
using Elsa.Liquid.Features;
using Elsa.Liquid.Implementations;
using Elsa.Liquid.Options;
using Elsa.Liquid.Services;
using Elsa.ServiceConfiguration.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Liquid.Extensions;
public static class DependencyInjectionExtensions
{
public static IServiceConfiguration UseLiquid(this IServiceConfiguration configuration, Action<LiquidConfigurator>? configure = default)
public static IModule UseLiquid(this IModule module, Action<LiquidConfigurator>? configure = default)
{
configuration.Configure(configure);
return configuration;
module.Configure(configure);
return module;
}
public static IServiceCollection AddLiquidFilter<T>(this IServiceCollection services, string name) where T : class, ILiquidFilter

View file

@ -1,6 +1,9 @@
using Elsa.Expressions.Configuration;
using Elsa.Expressions.Extensions;
using Elsa.Expressions.Features;
using Elsa.Expressions.Services;
using Elsa.Features.Abstractions;
using Elsa.Features.Attributes;
using Elsa.Features.Services;
using Elsa.Liquid.Expressions;
using Elsa.Liquid.Extensions;
using Elsa.Liquid.Filters;
@ -8,22 +11,19 @@ using Elsa.Liquid.Handlers;
using Elsa.Liquid.Implementations;
using Elsa.Liquid.Providers;
using Elsa.Liquid.Services;
using Elsa.Mediator.Configuration;
using Elsa.Mediator.Extensions;
using Elsa.MemoryCache.Configuration;
using Elsa.ServiceConfiguration.Abstractions;
using Elsa.ServiceConfiguration.Attributes;
using Elsa.ServiceConfiguration.Services;
using Elsa.Mediator.Features;
using Elsa.MemoryCache.Features;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Liquid.Configuration;
namespace Elsa.Liquid.Features;
[Dependency(typeof(MemoryCacheConfigurator))]
[Dependency(typeof(MediatorConfigurator))]
[Dependency(typeof(ExpressionsConfigurator))]
public class LiquidConfigurator : ConfiguratorBase
[DependsOn(typeof(MemoryCacheFeature))]
[DependsOn(typeof(MediatorFeature))]
[DependsOn(typeof(ExpressionsFeature))]
public class LiquidConfigurator : FeatureBase
{
public LiquidConfigurator(IServiceConfiguration serviceConfiguration) : base(serviceConfiguration)
public LiquidConfigurator(IModule serviceConfiguration) : base(serviceConfiguration)
{
}

View file

@ -11,7 +11,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Elsa.ServiceConfiguration\Elsa.ServiceConfiguration.csproj" />
<ProjectReference Include="..\..\common\Elsa.Features\Elsa.Features.csproj" />
</ItemGroup>
</Project>

View file

@ -1,5 +1,4 @@
using System.Reflection;
using Elsa.Mediator.Configuration;
using Elsa.Mediator.Implementations;
using Elsa.Mediator.Middleware.Command;
using Elsa.Mediator.Middleware.Command.Contracts;
@ -9,17 +8,18 @@ using Elsa.Mediator.Middleware.Request;
using Elsa.Mediator.Middleware.Request.Contracts;
using Elsa.Mediator.Models;
using Elsa.Mediator.Services;
using Elsa.ServiceConfiguration.Services;
using Elsa.Features.Services;
using Elsa.Mediator.Features;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Mediator.Extensions;
public static class DependencyInjectionExtensions
{
public static IServiceConfiguration AddMediator(this IServiceConfiguration serviceConfiguration, Action<MediatorConfigurator>? configure = default)
public static IModule AddMediator(this IModule module, Action<MediatorFeature>? configure = default)
{
serviceConfiguration.Configure(configure);
return serviceConfiguration;
module.Configure(configure);
return module;
}
public static IServiceCollection AddMediator(this IServiceCollection services)

View file

@ -0,0 +1,17 @@
using Elsa.Features.Abstractions;
using Elsa.Features.Services;
using Elsa.Mediator.Extensions;
namespace Elsa.Mediator.Features;
public class MediatorFeature : FeatureBase
{
public MediatorFeature(IModule module) : base(module)
{
}
public override void Apply()
{
Services.AddMediator();
}
}

Some files were not shown because too many files have changed in this diff Show more