2025-05-20 11:52:19 +00:00
|
|
|
using Elsa.Expressions.CSharp.Expressions;
|
2026-05-20 22:50:25 +00:00
|
|
|
using Elsa.Expressions.CSharp.Options;
|
2025-05-20 11:38:24 +00:00
|
|
|
using Elsa.Expressions.Contracts;
|
|
|
|
|
using Elsa.Expressions.Models;
|
|
|
|
|
using Elsa.Extensions;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2026-05-20 22:50:25 +00:00
|
|
|
using Microsoft.Extensions.Options;
|
2025-05-20 11:38:24 +00:00
|
|
|
|
2025-05-20 11:52:19 +00:00
|
|
|
namespace Elsa.Expressions.CSharp.Providers;
|
2025-05-20 11:38:24 +00:00
|
|
|
|
2026-05-20 22:50:25 +00:00
|
|
|
internal class CSharpExpressionDescriptorProvider(IOptions<CSharpOptions> options) : IExpressionDescriptorProvider
|
2025-05-20 11:38:24 +00:00
|
|
|
{
|
|
|
|
|
private const string TypeName = "CSharp";
|
|
|
|
|
|
|
|
|
|
public IEnumerable<ExpressionDescriptor> GetDescriptors()
|
|
|
|
|
{
|
|
|
|
|
yield return new()
|
|
|
|
|
{
|
|
|
|
|
Type = TypeName,
|
|
|
|
|
DisplayName = "C#",
|
2026-05-20 22:50:25 +00:00
|
|
|
IsBrowsable = options.Value.AllowHostCodeExecution,
|
2025-05-20 11:38:24 +00:00
|
|
|
Properties = new { MonacoLanguage = "csharp" }.ToDictionary(),
|
|
|
|
|
HandlerFactory = ActivatorUtilities.GetServiceOrCreateInstance<CSharpExpressionHandler>
|
|
|
|
|
};
|
|
|
|
|
}
|
2026-05-20 22:50:25 +00:00
|
|
|
}
|