| | | 1 | | using Elsa.Identity.Contracts; |
| | | 2 | | using Elsa.Identity.Entities; |
| | | 3 | | using Elsa.Identity.Models; |
| | | 4 | | using Elsa.Identity.Options; |
| | | 5 | | using JetBrains.Annotations; |
| | | 6 | | using Microsoft.Extensions.Options; |
| | | 7 | | |
| | | 8 | | namespace Elsa.Identity.Providers; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Represents an application provider that uses <see cref="ApplicationsOptions"/> to find applications. |
| | | 12 | | /// </summary> |
| | | 13 | | [PublicAPI] |
| | | 14 | | public class ConfigurationBasedApplicationProvider : IApplicationProvider |
| | | 15 | | { |
| | | 16 | | private readonly IOptions<ApplicationsOptions> _options; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Initializes a new instance of the <see cref="ConfigurationBasedApplicationProvider"/> class. |
| | | 20 | | /// </summary> |
| | 1 | 21 | | public ConfigurationBasedApplicationProvider(IOptions<ApplicationsOptions> options) |
| | | 22 | | { |
| | 1 | 23 | | _options = options; |
| | 1 | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <inheritdoc /> |
| | | 27 | | public Task<Application?> FindAsync(ApplicationFilter filter, CancellationToken cancellationToken = default) |
| | | 28 | | { |
| | 0 | 29 | | var applicationsQueryable = _options.Value.Applications.AsQueryable(); |
| | 0 | 30 | | var application = filter.Apply(applicationsQueryable).FirstOrDefault(); |
| | 0 | 31 | | return Task.FromResult(application); |
| | | 32 | | } |
| | | 33 | | } |