elsa-core/src/modules/Elsa.JavaScript/Providers/JavaScriptExpressionSyntaxProvider.cs

28 lines
1,000 B
C#
Raw Normal View History

using Elsa.Expressions.Contracts;
using Elsa.Expressions.Models;
using Elsa.Extensions;
using Elsa.JavaScript.Expressions;
using Elsa.Workflows.Core.Contracts;
using Microsoft.Extensions.DependencyInjection;
2022-01-11 12:28:21 +00:00
namespace Elsa.JavaScript.Providers;
2022-01-11 12:28:21 +00:00
internal class JavaScriptExpressionDescriptorProvider : IExpressionDescriptorProvider
2022-01-11 12:28:21 +00:00
{
private const string TypeName = "JavaScript";
2022-01-11 12:28:21 +00:00
public ValueTask<IEnumerable<ExpressionDescriptor>> GetDescriptorsAsync(CancellationToken cancellationToken = default)
2022-01-11 12:28:21 +00:00
{
var javaScript = CreateJavaScriptDescriptor();
return ValueTask.FromResult<IEnumerable<ExpressionDescriptor>>(new[] { javaScript });
2022-01-11 12:28:21 +00:00
}
private static ExpressionDescriptor CreateJavaScriptDescriptor() => new()
2022-01-12 10:43:46 +00:00
{
Type = TypeName,
DisplayName = "JavaScript",
Properties = new { MonacoLanguage = "javascript" }.ToDictionary(),
HandlerFactory = ActivatorUtilities.GetServiceOrCreateInstance<JavaScriptExpressionHandler>
2022-01-12 10:43:46 +00:00
};
2022-01-11 12:28:21 +00:00
}