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