| | | 1 | | using Elsa.Expressions.CSharp.Contracts; |
| | | 2 | | using Elsa.Expressions.Models; |
| | | 3 | | |
| | | 4 | | namespace Elsa.Expressions.CSharp.Extensions; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Provides extension methods for <see cref="ICSharpEvaluator"/>. |
| | | 8 | | /// </summary> |
| | | 9 | | public static class CSharpEvaluatorExtensions |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Evaluates a C# expression. |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="evaluator">The evaluator.</param> |
| | | 15 | | /// <param name="expression">The expression to evaluate.</param> |
| | | 16 | | /// <param name="returnType">The type of the return value.</param> |
| | | 17 | | /// <param name="context">The context in which the expression is evaluated.</param> |
| | | 18 | | /// <param name="options">An set of options.</param> |
| | | 19 | | /// <param name="cancellationToken">An optional cancellation token.</param> |
| | | 20 | | /// <returns>The result of the evaluation.</returns> |
| | | 21 | | public static async Task<object?> EvaluateAsync(this ICSharpEvaluator evaluator, |
| | | 22 | | string expression, |
| | | 23 | | Type returnType, |
| | | 24 | | ExpressionExecutionContext context, |
| | | 25 | | ExpressionEvaluatorOptions options, |
| | | 26 | | CancellationToken cancellationToken = default) |
| | | 27 | | { |
| | 0 | 28 | | return await evaluator.EvaluateAsync(expression, returnType, context, options, null, null, cancellationToken); |
| | 0 | 29 | | } |
| | | 30 | | } |