< 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: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 63
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.Python.ActivityDescriptorModifiers;
 3using Elsa.Expressions.Features;
 4using Elsa.Extensions;
 5using Elsa.Features.Abstractions;
 6using Elsa.Features.Attributes;
 7using Elsa.Features.Services;
 8using Elsa.Expressions.Python.Activities;
 9using Elsa.Expressions.Python.Contracts;
 10using Elsa.Expressions.Python.HostedServices;
 11using Elsa.Expressions.Python.Options;
 12using Elsa.Expressions.Python.Providers;
 13using Elsa.Expressions.Python.Services;
 14using Elsa.Workflows;
 15using Microsoft.Extensions.DependencyInjection;
 16
 17namespace Elsa.Expressions.Python.Features;
 18
 19/// <summary>
 20/// Installs Python integration.
 21/// </summary>
 22[DependsOn(typeof(MediatorFeature))]
 23[DependsOn(typeof(ExpressionsFeature))]
 24public class PythonFeature : FeatureBase
 25{
 26    /// <inheritdoc />
 327    public PythonFeature(IModule module) : base(module)
 28    {
 329    }
 30
 31    /// <summary>
 32    /// Configures the <see cref="Options.PythonOptions"/>.
 33    /// </summary>
 1534    public Action<PythonOptions> PythonOptions { get; set; } = _ => { };
 35
 36    /// <inheritdoc />
 37    public override void ConfigureHostedServices()
 38    {
 339        Module.ConfigureHostedService<PythonGlobalInterpreterManager>();
 340    }
 41
 42    /// <inheritdoc />
 43    public override void Apply()
 44    {
 345        Services.Configure(PythonOptions);
 46
 47        // Python services.
 348        Services
 349            .AddScoped<IPythonEvaluator, PythonNetPythonEvaluator>()
 350            .AddExpressionDescriptorProvider<PythonExpressionDescriptorProvider>()
 351            .AddSingleton<IActivityDescriptorModifier, PythonActivityDescriptorModifier>()
 352            ;
 53
 54        // Handlers.
 355        Services.AddNotificationHandlersFrom<PythonFeature>();
 56
 57        // Activities.
 358        Module.AddActivitiesFrom<PythonFeature>();
 59
 60        // UI property handlers.
 361        Services.AddScoped<IPropertyUIHandler, RunPythonOptionsProvider>();
 362    }
 63}