| | | 1 | | using Elsa.Expressions.Contracts; |
| | | 2 | | using Elsa.Expressions.Models; |
| | | 3 | | |
| | | 4 | | namespace Elsa.Workflows.Management.Services; |
| | | 5 | | |
| | | 6 | | /// <inheritdoc /> |
| | | 7 | | public class ExpressionDescriptorRegistry : IExpressionDescriptorRegistry |
| | | 8 | | { |
| | 330 | 9 | | private readonly IDictionary<string, ExpressionDescriptor> _expressionSyntaxDescriptors = new Dictionary<string, Exp |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Represents a registry of expression descriptors. |
| | | 13 | | /// </summary> |
| | 330 | 14 | | public ExpressionDescriptorRegistry(IEnumerable<IExpressionDescriptorProvider> providers) |
| | | 15 | | { |
| | 1330 | 16 | | foreach (var provider in providers) |
| | | 17 | | { |
| | 335 | 18 | | var descriptors = provider.GetDescriptors(); |
| | 335 | 19 | | AddRange(descriptors); |
| | | 20 | | } |
| | 330 | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <inheritdoc /> |
| | | 24 | | public void Add(ExpressionDescriptor descriptor) |
| | | 25 | | { |
| | 1919 | 26 | | _expressionSyntaxDescriptors[descriptor.Type] = descriptor; |
| | 1919 | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <inheritdoc /> |
| | | 30 | | public void AddRange(IEnumerable<ExpressionDescriptor> descriptors) |
| | | 31 | | { |
| | 4508 | 32 | | foreach (var descriptor in descriptors) |
| | 1918 | 33 | | Add(descriptor); |
| | 336 | 34 | | } |
| | | 35 | | |
| | | 36 | | /// <inheritdoc /> |
| | 6 | 37 | | public IEnumerable<ExpressionDescriptor> ListAll() => _expressionSyntaxDescriptors.Values; |
| | | 38 | | |
| | | 39 | | /// <inheritdoc /> |
| | 2 | 40 | | public ExpressionDescriptor? Find(Func<ExpressionDescriptor, bool> predicate) => _expressionSyntaxDescriptors.Values |
| | | 41 | | |
| | | 42 | | /// <inheritdoc /> |
| | 7329 | 43 | | public ExpressionDescriptor? Find(string type) => _expressionSyntaxDescriptors.TryGetValue(type, out var descriptor) |
| | | 44 | | } |