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