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
Jean-Baptiste Dalle committed Nov 21, 2023
1 parent 81c5102 commit 689016e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 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
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 689016e

Please sign in to comment.