< Summary

Information
Class: Elsa.Expressions.CSharp.Handlers.ConfigureScriptsFromOptions
Assembly: Elsa.Expressions.CSharp
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.CSharp/Handlers/ConfigureScriptsFromOptions.cs
Line coverage
37%
Covered lines: 3
Uncovered lines: 5
Coverable lines: 8
Total lines: 37
Line coverage: 37.5%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
HandleAsync(...)0%2040%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.CSharp/Handlers/ConfigureScriptsFromOptions.cs

#LineLine coverage
 1using Elsa.Expressions.CSharp.Notifications;
 2using Elsa.Expressions.CSharp.Options;
 3using Elsa.Mediator.Contracts;
 4using JetBrains.Annotations;
 5using Microsoft.CodeAnalysis.Scripting;
 6using Microsoft.Extensions.Options;
 7
 8namespace Elsa.Expressions.CSharp.Handlers;
 9
 10/// <summary>
 11/// This handler configures the <see cref="ScriptOptions"/> and <see cref="Script"/> from the <see cref="CSharpOptions"/
 12/// </summary>
 13[UsedImplicitly]
 14public class ConfigureScriptsFromOptions : INotificationHandler<EvaluatingCSharp>
 15{
 16    private readonly CSharpOptions _options;
 17
 18    /// <summary>
 19    /// Initializes a new instance of the <see cref="ConfigureScriptsFromOptions"/> class.
 20    /// </summary>
 31921    public ConfigureScriptsFromOptions(IOptions<CSharpOptions> options)
 22    {
 31923        _options = options.Value;
 31924    }
 25
 26    /// <inheritdoc />
 27    public Task HandleAsync(EvaluatingCSharp notification, CancellationToken cancellationToken)
 28    {
 029        foreach (var scriptOptionsCallback in _options.ConfigureScriptOptionsCallbacks)
 030            notification.ScriptOptions = scriptOptionsCallback(notification.ScriptOptions, notification.Context);
 31
 032        foreach (var scriptCallback in _options.ConfigureScriptCallbacks)
 033            notification.Script = scriptCallback(notification.Script, notification.Context);
 34
 035        return Task.CompletedTask;
 36    }
 37}