Fixed the issue with setVariable execution in javascript activity (#4158)
* Fixed the issue with setVariable execution in javascript activity
This commit is contained in:
parent
4857a12b79
commit
07b6aedbec
|
|
@ -62,8 +62,8 @@ public class JintJavaScriptEvaluator : IJavaScriptEvaluator
|
|||
engine.SetValue("getWorkflowInstanceId", (Func<string>)(() => context.GetActivityExecutionContext().WorkflowExecutionContext.Id));
|
||||
engine.SetValue("setCorrelationId", (Action<string?>)(value => context.GetActivityExecutionContext().WorkflowExecutionContext.CorrelationId = value));
|
||||
engine.SetValue("getCorrelationId", (Func<string?>)(() => context.GetActivityExecutionContext().WorkflowExecutionContext.CorrelationId));
|
||||
engine.SetValue("setVariable", (Action<string, object>)((id, value) => context.SetVariable(id, value)));
|
||||
engine.SetValue("getVariable", (Func<string, object?>)(id => context.GetVariable(id)));
|
||||
engine.SetValue("setVariable", (Action<string, object>)((name, value) => SetVariableInScope(context, name, value)));
|
||||
engine.SetValue("getVariable", (Func<string, object?>)(name => GetVariableInScope(context, name)));
|
||||
engine.SetValue("getInput", (Func<string, object?>)(name => context.GetWorkflowExecutionContext().Input.GetValue(name)));
|
||||
engine.SetValue("getOutputFrom", (Func<string, string?, object?>)((activityIdOrNodeId, outputName) => GetOutput(context, activityIdOrNodeId, outputName)));
|
||||
engine.SetValue("getLastResult", (Func<object?>)(() => GetLastResult(context)));
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ public static class ExpressionExecutionContextExtensions
|
|||
public static T? Get<T>(this ExpressionExecutionContext context, Input<T>? input) => input != null ? context.GetBlock(input.MemoryBlockReference).Value.ConvertTo<T>() : default;
|
||||
public static T? Get<T>(this ExpressionExecutionContext context, Output output) => context.GetBlock(output.MemoryBlockReference).Value.ConvertTo<T>();
|
||||
public static object? Get(this ExpressionExecutionContext context, Output output) => context.GetBlock(output.MemoryBlockReference).Value;
|
||||
public static T? GetVariable<T>(this ExpressionExecutionContext context, string id) => (T?)context.GetVariable(id);
|
||||
public static object? GetVariable(this ExpressionExecutionContext context, string id) => new Variable(id).Get(context);
|
||||
public static Variable SetVariable<T>(this ExpressionExecutionContext context, string id, T? value, Type? storageDriverType = default) => context.SetVariable(id, (object?)value, storageDriverType, default);
|
||||
public static T? GetVariable<T>(this ExpressionExecutionContext context, string name) => (T?)context.GetVariable(name);
|
||||
public static object? GetVariable(this ExpressionExecutionContext context, string name) => new Variable(name).Get(context);
|
||||
public static Variable SetVariable<T>(this ExpressionExecutionContext context, string name, T? value, Type? storageDriverType = default) => context.SetVariable(name, (object?)value, storageDriverType, default);
|
||||
|
||||
public static Variable SetVariable(this ExpressionExecutionContext context, string id, object? value, Type? storageDriverType, Action<MemoryBlock>? configure = default)
|
||||
public static Variable SetVariable(this ExpressionExecutionContext context, string name, object? value, Type? storageDriverType, Action<MemoryBlock>? configure = default)
|
||||
{
|
||||
var variable = new Variable(id, value)
|
||||
var variable = new Variable(name, value)
|
||||
{
|
||||
StorageDriverType = storageDriverType
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,13 +11,14 @@ public class Variable : MemoryBlockReference
|
|||
Id = Guid.NewGuid().ToString("N");
|
||||
}
|
||||
|
||||
public Variable(string id)
|
||||
public Variable(string name) : this()
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public Variable(string id, object? value = default) : this(id)
|
||||
public Variable(string name, object? value = default) : this()
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue