Skip to content

Commit

Permalink
fix: change scope of python and csharp features
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanbaptistedalle committed Nov 24, 2023
1 parent 62131c9 commit 0fdca0a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 22 deletions.
12 changes: 5 additions & 7 deletions src/modules/Elsa.CSharp/Features/CSharpFeature.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Elsa.Common.Features;
using Elsa.CSharp.Contracts;
using Elsa.CSharp.Expressions;
using Elsa.CSharp.Options;
using Elsa.CSharp.Providers;
using Elsa.CSharp.Services;
using Elsa.Expressions.Contracts;
using Elsa.Expressions.Features;
using Elsa.Extensions;
using Elsa.Features.Abstractions;
Expand All @@ -25,26 +23,26 @@ public class CSharpFeature : FeatureBase
public CSharpFeature(IModule module) : base(module)
{
}

/// <summary>
/// Configures the <see cref="CSharpOptions"/>.
/// </summary>
public Action<CSharpOptions> CSharpOptions { get; set; } = _ => { };

/// <inheritdoc />
public override void Apply()
{
Services.Configure(CSharpOptions);

// C# services.
Services
.AddExpressionDescriptorProvider<CSharpExpressionDescriptorProvider>()
.AddSingleton<ICSharpEvaluator, CSharpEvaluator>()
.AddScoped<ICSharpEvaluator, CSharpEvaluator>()
;

// Handlers.
Services.AddNotificationHandlersFrom<CSharpFeature>();

// Activities.
Module.AddActivitiesFrom<CSharpFeature>();
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Elsa.Dsl/Features/DslFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public DslFeature(IModule module) : base(module)
public override void Configure()
{
Services
.AddSingleton<IDslEngine, DslEngine>()
.AddScoped<IDslEngine, DslEngine>()
.AddSingleton<ITypeSystem, TypeSystem>()
.AddSingleton<IFunctionActivityRegistry, FunctionActivityRegistry>();
}
Expand Down
12 changes: 2 additions & 10 deletions src/modules/Elsa.Http/Middleware/WorkflowsMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
using Elsa.Extensions;
using Elsa.Http.Bookmarks;
using Elsa.Http.Contracts;
using Elsa.Http.Models;
using Elsa.Http.Options;
using Elsa.Workflows.Core;
using Elsa.Workflows.Core.Contracts;
using Elsa.Workflows.Core.Helpers;
using Elsa.Workflows.Runtime.Contracts;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using System.Net;
using System.Net.Mime;
using System.Text.Json;
using Elsa.Extensions;
using Elsa.Http.Bookmarks;
using Elsa.Workflows.Core;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.State;
using Elsa.Workflows.Runtime.Contracts;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Elsa.Python/Features/PythonFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override void Apply()

// Python services.
Services
.AddSingleton<IPythonEvaluator, PythonNetPythonEvaluator>()
.AddScoped<IPythonEvaluator, PythonNetPythonEvaluator>()
.AddExpressionDescriptorProvider<PythonExpressionDescriptorProvider>()
;

Expand Down
4 changes: 2 additions & 2 deletions src/modules/Elsa.Quartz/Features/QuartzSchedulerFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void Configure()
{
// Configure the scheduling feature to use the Quartz workflow scheduler.
scheduling.WorkflowScheduler = sp => sp.GetRequiredService<QuartzWorkflowScheduler>();
// Configure the cron parser to use the Quartz cron parser.
scheduling.CronParser = sp => sp.GetRequiredService<QuartzCronParser>();
});
Expand All @@ -39,7 +39,7 @@ public override void Configure()
/// <inheritdoc />
public override void Apply()
{
Services.AddScoped<IActivityDescriptorModifier, CronActivityDescriptorModifier>();
Services.AddSingleton<IActivityDescriptorModifier, CronActivityDescriptorModifier>();
Services.AddScoped<QuartzWorkflowScheduler>();
Services.AddScoped<QuartzCronParser>();
Services.AddQuartz(quartz => quartz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public WorkflowContextsJavaScriptFeature(IModule module) : base(module)
/// <inheritdoc />
public override void Apply()
{
Services.AddSingleton<ConfigureJavaScriptEngine>();
Services.AddScoped<ConfigureJavaScriptEngine>();
Services.AddNotificationHandler<ConfigureJavaScriptEngine, EvaluatingJavaScript>(sp => sp.GetRequiredService<ConfigureJavaScriptEngine>());
Services.AddTypeDefinitionProvider<ConfigureJavaScriptEngine>(sp => sp.GetRequiredService<ConfigureJavaScriptEngine>());
Services.AddFunctionDefinitionProvider<ConfigureJavaScriptEngine>(sp => sp.GetRequiredService<ConfigureJavaScriptEngine>());
Expand Down

0 comments on commit 0fdca0a

Please sign in to comment.