| | | 1 | | using Elsa.Expressions.Models; |
| | | 2 | | using Elsa.Mediator.Contracts; |
| | | 3 | | using Microsoft.CodeAnalysis.Scripting; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Expressions.CSharp.Notifications; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// This notification is published every time a C# expression is about to be evaluated. |
| | | 9 | | /// It gives subscribers a chance to configure the <see cref="ScriptOptions"/> with additional functions and variables. |
| | | 10 | | /// </summary> |
| | 0 | 11 | | public record EvaluatingCSharp(ExpressionEvaluatorOptions Options, Script Script, ScriptOptions ScriptOptions, Expressio |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Configures the <see cref="ScriptOptions"/> with additional functions and variables. |
| | | 15 | | /// </summary> |
| | | 16 | | public EvaluatingCSharp ConfigureScriptOptions(Func<ScriptOptions, ScriptOptions> scriptOptions) |
| | | 17 | | { |
| | 0 | 18 | | ScriptOptions = scriptOptions(ScriptOptions); |
| | 0 | 19 | | return this; |
| | | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// Appends the specified script to the current script. |
| | | 24 | | /// </summary> |
| | | 25 | | public EvaluatingCSharp AppendScript(string script) |
| | | 26 | | { |
| | 0 | 27 | | Script = Script.ContinueWith(script, ScriptOptions); |
| | 0 | 28 | | return this; |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// The <see cref="ScriptOptions"/> that will be used to evaluate the expression. |
| | | 33 | | /// </summary> |
| | 0 | 34 | | public ScriptOptions ScriptOptions { get; set; } = ScriptOptions; |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// The <see cref="ScriptState"/> that will be used to evaluate the expression. |
| | | 38 | | /// </summary> |
| | 0 | 39 | | public Script Script { get; set; } = Script; |
| | | 40 | | } |