| | | 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 type definition providers. |
| | | 9 | | /// </summary> |
| | | 10 | | public abstract class TypeDefinitionProvider : ITypeDefinitionProvider |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Returns a list of type definitions to the system. |
| | | 14 | | /// </summary> |
| | | 15 | | protected virtual ValueTask<IEnumerable<TypeDefinition>> GetTypeDefinitionsAsync(TypeDefinitionContext context) |
| | | 16 | | { |
| | 0 | 17 | | var functions = GetTypeDefinitions(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<TypeDefinition> GetTypeDefinitions(TypeDefinitionContext context) |
| | | 25 | | { |
| | 0 | 26 | | yield break; |
| | | 27 | | } |
| | | 28 | | |
| | 0 | 29 | | async ValueTask<IEnumerable<TypeDefinition>> ITypeDefinitionProvider.GetTypeDefinitionsAsync(TypeDefinitionContext c |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Provides a fluid API to build a type definition. |
| | | 33 | | /// </summary> |
| | | 34 | | protected TypeDefinition CreateTypeDefinition(Action<TypeDefinitionBuilder> setup) |
| | | 35 | | { |
| | 0 | 36 | | var builder = new TypeDefinitionBuilder(); |
| | 0 | 37 | | setup(builder); |
| | 0 | 38 | | return builder.BuildTypeDefinition(); |
| | | 39 | | } |
| | | 40 | | } |