< 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: 56
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.Common.ShellFeatures;
 3using Elsa.Expressions.Python.Activities;
 4using Elsa.Expressions.Python.ActivityDescriptorModifiers;
 5using Elsa.Expressions.Python.Contracts;
 6using Elsa.Expressions.Python.HostedServices;
 7using Elsa.Expressions.Python.Options;
 8using Elsa.Expressions.Python.Providers;
 9using Elsa.Expressions.Python.Services;
 10using Elsa.Expressions.ShellFeatures;
 11using Elsa.Extensions;
 12using Elsa.Workflows;
 13using Elsa.Platform.PackageManifest.Generator.Hints;
 14using JetBrains.Annotations;
 15using Microsoft.Extensions.DependencyInjection;
 16
 17namespace Elsa.Expressions.Python.ShellFeatures;
 18
 19/// <summary>
 20/// Installs Python integration.
 21/// </summary>
 22[ManifestFeatureCategory("Expressions")]
 23[ManifestFeatureCategory("Scripting")]
 24[ShellFeature(
 25    DisplayName = "Python Expressions",
 26    Description = "Provides Python expression evaluation capabilities for workflows",
 27    DependsOn = [typeof(MediatorFeature), typeof(ExpressionsFeature)])]
 28[UsedImplicitly]
 29public class PythonFeature : IShellFeature
 30{
 31    /// <summary>
 32    /// Configures the <see cref="Options.PythonOptions"/>.
 33    /// </summary>
 034    public Action<PythonOptions> PythonOptions { get; set; } = _ => { };
 35
 36    public void ConfigureServices(IServiceCollection services)
 37    {
 038        services.Configure(PythonOptions);
 39
 40        // Python services.
 041        services
 042            .AddScoped<IPythonEvaluator, PythonNetPythonEvaluator>()
 043            .AddExpressionDescriptorProvider<PythonExpressionDescriptorProvider>()
 044            .AddSingleton<IActivityDescriptorModifier, PythonActivityDescriptorModifier>();
 45
 46        // Handlers.
 047        services.AddNotificationHandlersFrom<PythonFeature>();
 48
 49        // UI property handlers.
 050        services.AddScoped<IPropertyUIHandler, RunPythonOptionsProvider>();
 51
 52        // Hosted services.
 053        services.AddHostedService<PythonGlobalInterpreterManager>();
 054    }
 55}
 56