| | | 1 | | using Elsa.Common.Features; |
| | | 2 | | using Elsa.Expressions.Features; |
| | | 3 | | using Elsa.Extensions; |
| | | 4 | | using Elsa.Features.Abstractions; |
| | | 5 | | using Elsa.Features.Attributes; |
| | | 6 | | using Elsa.Features.Services; |
| | | 7 | | using Elsa.Expressions.Python.Activities; |
| | | 8 | | using Elsa.Expressions.Python.Contracts; |
| | | 9 | | using Elsa.Expressions.Python.HostedServices; |
| | | 10 | | using Elsa.Expressions.Python.Options; |
| | | 11 | | using Elsa.Expressions.Python.Providers; |
| | | 12 | | using Elsa.Expressions.Python.Services; |
| | | 13 | | using Elsa.Workflows; |
| | | 14 | | using Microsoft.Extensions.DependencyInjection; |
| | | 15 | | |
| | | 16 | | namespace Elsa.Expressions.Python.Features; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Installs Python integration. |
| | | 20 | | /// </summary> |
| | | 21 | | [DependsOn(typeof(MediatorFeature))] |
| | | 22 | | [DependsOn(typeof(ExpressionsFeature))] |
| | | 23 | | public class PythonFeature : FeatureBase |
| | | 24 | | { |
| | | 25 | | /// <inheritdoc /> |
| | 1 | 26 | | public PythonFeature(IModule module) : base(module) |
| | | 27 | | { |
| | 1 | 28 | | } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Configures the <see cref="Options.PythonOptions"/>. |
| | | 32 | | /// </summary> |
| | 5 | 33 | | public Action<PythonOptions> PythonOptions { get; set; } = _ => { }; |
| | | 34 | | |
| | | 35 | | /// <inheritdoc /> |
| | | 36 | | public override void ConfigureHostedServices() |
| | | 37 | | { |
| | 1 | 38 | | Module.ConfigureHostedService<PythonGlobalInterpreterManager>(); |
| | 1 | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <inheritdoc /> |
| | | 42 | | public override void Apply() |
| | | 43 | | { |
| | 1 | 44 | | Services.Configure(PythonOptions); |
| | | 45 | | |
| | | 46 | | // Python services. |
| | 1 | 47 | | Services |
| | 1 | 48 | | .AddScoped<IPythonEvaluator, PythonNetPythonEvaluator>() |
| | 1 | 49 | | .AddExpressionDescriptorProvider<PythonExpressionDescriptorProvider>() |
| | 1 | 50 | | ; |
| | | 51 | | |
| | | 52 | | // Handlers. |
| | 1 | 53 | | Services.AddNotificationHandlersFrom<PythonFeature>(); |
| | | 54 | | |
| | | 55 | | // Activities. |
| | 1 | 56 | | Module.AddActivitiesFrom<PythonFeature>(); |
| | | 57 | | |
| | | 58 | | // UI property handlers. |
| | 1 | 59 | | Services.AddScoped<IPropertyUIHandler, RunPythonOptionsProvider>(); |
| | 1 | 60 | | } |
| | | 61 | | } |