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