| | | 1 | | using Elsa.Expressions.JavaScript.TypeDefinitions.Builders; |
| | | 2 | | using Elsa.Expressions.JavaScript.TypeDefinitions.Contracts; |
| | | 3 | | using Elsa.Expressions.JavaScript.TypeDefinitions.Models; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Expressions.JavaScript.TypeDefinitions.Abstractions; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// A base class for function definition providers. |
| | | 9 | | /// </summary> |
| | | 10 | | public abstract class FunctionDefinitionProvider : IFunctionDefinitionProvider |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Returns a list of type definitions to the system. |
| | | 14 | | /// </summary> |
| | | 15 | | protected virtual ValueTask<IEnumerable<FunctionDefinition>> GetFunctionDefinitionsAsync(TypeDefinitionContext conte |
| | | 16 | | { |
| | 0 | 17 | | var functions = GetFunctionDefinitions(context); |
| | 0 | 18 | | return new(functions); |
| | | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Returns a list of type definitions to the system. |
| | | 23 | | /// </summary> |
| | | 24 | | protected virtual IEnumerable<FunctionDefinition> GetFunctionDefinitions(TypeDefinitionContext context) |
| | | 25 | | { |
| | 0 | 26 | | yield break; |
| | | 27 | | } |
| | | 28 | | |
| | 0 | 29 | | async ValueTask<IEnumerable<FunctionDefinition>> IFunctionDefinitionProvider.GetFunctionDefinitionsAsync(TypeDefinit |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Provides a fluid API to build a function definition. |
| | | 33 | | /// </summary> |
| | | 34 | | protected FunctionDefinition CreateFunctionDefinition(Action<FunctionDefinitionBuilder> setup) |
| | | 35 | | { |
| | 0 | 36 | | var builder = new FunctionDefinitionBuilder(); |
| | 0 | 37 | | setup(builder); |
| | 0 | 38 | | return builder.BuildFunctionDefinition(); |
| | | 39 | | } |
| | | 40 | | } |