< Summary

Information
Class: Elsa.Expressions.Python.Notifications.EvaluatingPython
Assembly: Elsa.Expressions.Python
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Python/Notifications/EvaluatingPython.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 32
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Scope()100%210%
AppendScript(...)100%210%
AppendScript(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Python/Notifications/EvaluatingPython.cs

#LineLine coverage
 1using System.Text;
 2using Elsa.Expressions.Models;
 3using Elsa.Mediator.Contracts;
 4using Python.Runtime;
 5
 6namespace Elsa.Expressions.Python.Notifications;
 7
 8/// <summary>
 9/// This notification is published every time a Python expression is about to be evaluated, giving subscribers a chance 
 10/// </summary>
 011public record EvaluatingPython(PyModule Scope, ExpressionExecutionContext Context) : INotification
 12{
 13    /// <summary>
 14    /// Appends a script to the Python engine.
 15    /// </summary>
 16    /// <param name="builder">A builder that builds the script to append.</param>
 17    public void AppendScript(Action<StringBuilder> builder)
 18    {
 019        var sb = new StringBuilder();
 020        builder(sb);
 021        AppendScript(sb.ToString());
 022    }
 23
 24    /// <summary>
 25    /// Appends a script to the Python engine.
 26    /// </summary>
 27    /// <param name="script">The script to append.</param>
 28    public void AppendScript(string script)
 29    {
 030        Scope.Exec(script);
 031    }
 32}