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