< Summary

Information
Class: Elsa.Expressions.Python.ShellFeatures.PythonFeature
Assembly: Elsa.Expressions.Python
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Python/ShellFeatures/PythonFeature.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 10
Coverable lines: 10
Total lines: 51
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_PythonOptions()100%210%
ConfigureServices(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Python/ShellFeatures/PythonFeature.cs

#LineLine coverage
 1using CShells.Features;
 2using Elsa.Expressions.Python.ActivityDescriptorModifiers;
 3using Elsa.Expressions.Python.Activities;
 4using Elsa.Expressions.Python.Contracts;
 5using Elsa.Expressions.Python.HostedServices;
 6using Elsa.Expressions.Python.Options;
 7using Elsa.Expressions.Python.Providers;
 8using Elsa.Expressions.Python.Services;
 9using Elsa.Extensions;
 10using Elsa.Workflows;
 11using JetBrains.Annotations;
 12using Microsoft.Extensions.DependencyInjection;
 13
 14namespace Elsa.Expressions.Python.ShellFeatures;
 15
 16/// <summary>
 17/// Installs Python integration.
 18/// </summary>
 19[ShellFeature(
 20    DisplayName = "Python Expressions",
 21    Description = "Provides Python expression evaluation capabilities for workflows",
 22    DependsOn = ["Mediator", "Expressions"])]
 23[UsedImplicitly]
 24public class PythonFeature : IShellFeature
 25{
 26    /// <summary>
 27    /// Configures the <see cref="Options.PythonOptions"/>.
 28    /// </summary>
 029    public Action<PythonOptions> PythonOptions { get; set; } = _ => { };
 30
 31    public void ConfigureServices(IServiceCollection services)
 32    {
 033        services.Configure(PythonOptions);
 34
 35        // Python services.
 036        services
 037            .AddScoped<IPythonEvaluator, PythonNetPythonEvaluator>()
 038            .AddExpressionDescriptorProvider<PythonExpressionDescriptorProvider>()
 039            .AddSingleton<IActivityDescriptorModifier, PythonActivityDescriptorModifier>();
 40
 41        // Handlers.
 042        services.AddNotificationHandlersFrom<PythonFeature>();
 43
 44        // UI property handlers.
 045        services.AddScoped<IPropertyUIHandler, RunPythonOptionsProvider>();
 46
 47        // Hosted services.
 048        services.AddHostedService<PythonGlobalInterpreterManager>();
 049    }
 50}
 51