2023-11-03 19:28:10 +00:00
|
|
|
using Elsa.Common.Features;
|
|
|
|
|
using Elsa.CSharp.Contracts;
|
|
|
|
|
using Elsa.CSharp.Expressions;
|
|
|
|
|
using Elsa.CSharp.Options;
|
|
|
|
|
using Elsa.CSharp.Providers;
|
|
|
|
|
using Elsa.CSharp.Services;
|
|
|
|
|
using Elsa.Expressions.Contracts;
|
|
|
|
|
using Elsa.Expressions.Features;
|
|
|
|
|
using Elsa.Extensions;
|
|
|
|
|
using Elsa.Features.Abstractions;
|
|
|
|
|
using Elsa.Features.Attributes;
|
|
|
|
|
using Elsa.Features.Services;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
namespace Elsa.CSharp.Features;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Installs C# integration.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DependsOn(typeof(MediatorFeature))]
|
|
|
|
|
[DependsOn(typeof(ExpressionsFeature))]
|
|
|
|
|
public class CSharpFeature : FeatureBase
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public CSharpFeature(IModule module) : base(module)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-11-04 17:15:56 +00:00
|
|
|
/// Configures the <see cref="CSharpOptions"/>.
|
2023-11-03 19:28:10 +00:00
|
|
|
/// </summary>
|
2023-11-04 17:15:56 +00:00
|
|
|
public Action<CSharpOptions> CSharpOptions { get; set; } = _ => { };
|
2023-11-03 19:28:10 +00:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public override void Apply()
|
|
|
|
|
{
|
2023-11-04 17:15:56 +00:00
|
|
|
Services.Configure(CSharpOptions);
|
2023-11-03 19:28:10 +00:00
|
|
|
|
|
|
|
|
// C# services.
|
|
|
|
|
Services
|
|
|
|
|
.AddSingleton<IExpressionSyntaxProvider, CSharpExpressionSyntaxProvider>()
|
|
|
|
|
.AddSingleton<ICSharpEvaluator, CSharpEvaluator>()
|
|
|
|
|
.AddExpressionHandler<CSharpExpressionHandler, CSharpExpression>()
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// Handlers.
|
|
|
|
|
Services.AddNotificationHandlersFrom<CSharpFeature>();
|
|
|
|
|
|
|
|
|
|
// Activities.
|
|
|
|
|
Module.AddActivitiesFrom<CSharpFeature>();
|
|
|
|
|
}
|
|
|
|
|
}
|