< Summary

Information
Class: Elsa.Expressions.Python.Features.PythonFeature
Assembly: Elsa.Expressions.Python
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Python/Features/PythonFeature.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 61
Line coverage: 100%
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
.ctor(...)100%11100%
get_PythonOptions()100%11100%
ConfigureHostedServices()100%11100%
Apply()100%11100%

File(s)

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

#LineLine coverage
 1using Elsa.Common.Features;
 2using Elsa.Expressions.Features;
 3using Elsa.Extensions;
 4using Elsa.Features.Abstractions;
 5using Elsa.Features.Attributes;
 6using Elsa.Features.Services;
 7using Elsa.Expressions.Python.Activities;
 8using Elsa.Expressions.Python.Contracts;
 9using Elsa.Expressions.Python.HostedServices;
 10using Elsa.Expressions.Python.Options;
 11using Elsa.Expressions.Python.Providers;
 12using Elsa.Expressions.Python.Services;
 13using Elsa.Workflows;
 14using Microsoft.Extensions.DependencyInjection;
 15
 16namespace Elsa.Expressions.Python.Features;
 17
 18/// <summary>
 19/// Installs Python integration.
 20/// </summary>
 21[DependsOn(typeof(MediatorFeature))]
 22[DependsOn(typeof(ExpressionsFeature))]
 23public class PythonFeature : FeatureBase
 24{
 25    /// <inheritdoc />
 126    public PythonFeature(IModule module) : base(module)
 27    {
 128    }
 29
 30    /// <summary>
 31    /// Configures the <see cref="Options.PythonOptions"/>.
 32    /// </summary>
 533    public Action<PythonOptions> PythonOptions { get; set; } = _ => { };
 34
 35    /// <inheritdoc />
 36    public override void ConfigureHostedServices()
 37    {
 138        Module.ConfigureHostedService<PythonGlobalInterpreterManager>();
 139    }
 40
 41    /// <inheritdoc />
 42    public override void Apply()
 43    {
 144        Services.Configure(PythonOptions);
 45
 46        // Python services.
 147        Services
 148            .AddScoped<IPythonEvaluator, PythonNetPythonEvaluator>()
 149            .AddExpressionDescriptorProvider<PythonExpressionDescriptorProvider>()
 150            ;
 51
 52        // Handlers.
 153        Services.AddNotificationHandlersFrom<PythonFeature>();
 54
 55        // Activities.
 156        Module.AddActivitiesFrom<PythonFeature>();
 57
 58        // UI property handlers.
 159        Services.AddScoped<IPropertyUIHandler, RunPythonOptionsProvider>();
 160    }
 61}