Skip to content

Commit

Permalink
Jint options configuration (elsa-workflows#3178)
Browse files Browse the repository at this point in the history
* Adding notification to intecept jint options

* Moving notificiation into it's own file
  • Loading branch information
stuartmcgillivray authored Jul 11, 2022
1 parent 520e3d3 commit e840d12
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Elsa.Services.Models;
using MediatR;

namespace Elsa.Scripting.JavaScript.Messages
{
public class ConfigureJavaScriptOptions : INotification
{
public ConfigureJavaScriptOptions(Jint.Options options, ActivityExecutionContext context)
{
JintOptions = options;
ActivityExecutionContext = context;
}
public Jint.Options JintOptions { get; set; }
public ActivityExecutionContext ActivityExecutionContext { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Elsa.Services.Models;
using Elsa.Services.Models;
using Jint;
using MediatR;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading;
using System.Threading.Tasks;
using Elsa.Scripting.JavaScript.Converters.Jint;
Expand Down Expand Up @@ -45,8 +45,10 @@ public JintJavaScriptEvaluator(

private async Task<Engine> GetConfiguredEngine(Action<Engine>? configureEngine, ActivityExecutionContext context, CancellationToken cancellationToken)
{
var engine = new Engine(opts =>
var engine = new Engine(async opts =>
{
await _mediator.Publish(new ConfigureJavaScriptOptions(opts, context));

opts.AddObjectConverter<ByteArrayConverter>();
if (_scriptOptions.AllowClr)
opts.AllowClr();
Expand Down

0 comments on commit e840d12

Please sign in to comment.