* Scaffold Python project * Add Workflow Variable accessor * Add RunPython activity * Add option to register scripts via options
28 lines
849 B
C#
28 lines
849 B
C#
using Elsa.Expressions.Contracts;
|
|
using Elsa.Expressions.Models;
|
|
using Elsa.Python.Contracts;
|
|
|
|
namespace Elsa.Python.Expressions;
|
|
|
|
/// <summary>
|
|
/// Evaluates C# expressions.
|
|
/// </summary>
|
|
public class PythonExpressionHandler : IExpressionHandler
|
|
{
|
|
private readonly IPythonEvaluator _evaluator;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="PythonExpressionHandler"/> class.
|
|
/// </summary>
|
|
public PythonExpressionHandler(IPythonEvaluator evaluator)
|
|
{
|
|
_evaluator = evaluator;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public async ValueTask<object?> EvaluateAsync(IExpression expression, Type returnType, ExpressionExecutionContext context)
|
|
{
|
|
var pythonExpression = (PythonExpression)expression;
|
|
return await _evaluator.EvaluateAsync(pythonExpression.Value, returnType, context);
|
|
}
|
|
} |