| | | 1 | | using Elsa.Expressions.CSharp.Contracts; |
| | | 2 | | using Elsa.Expressions.Contracts; |
| | | 3 | | using Elsa.Expressions.Helpers; |
| | | 4 | | using Elsa.Expressions.Models; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Expressions.CSharp.Expressions; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Evaluates C# expressions. |
| | | 10 | | /// </summary> |
| | | 11 | | public class CSharpExpressionHandler : IExpressionHandler |
| | | 12 | | { |
| | | 13 | | private readonly ICSharpEvaluator _cSharpEvaluator; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Initializes a new instance of the <see cref="CSharpExpressionHandler"/> class. |
| | | 17 | | /// </summary> |
| | 0 | 18 | | public CSharpExpressionHandler(ICSharpEvaluator cSharpEvaluator) |
| | | 19 | | { |
| | 0 | 20 | | _cSharpEvaluator = cSharpEvaluator; |
| | 0 | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <inheritdoc /> |
| | | 24 | | public async ValueTask<object?> EvaluateAsync(Expression expression, Type returnType, ExpressionExecutionContext con |
| | | 25 | | { |
| | 0 | 26 | | var script = expression.Value.ConvertTo<string>() ?? ""; |
| | 0 | 27 | | return await _cSharpEvaluator.EvaluateAsync(script, returnType, context, options); |
| | 0 | 28 | | } |
| | | 29 | | } |