| | 1 | | using Fluorite.Strainer.Models; |
| | 2 | | using Fluorite.Strainer.Services; |
| | 3 | | using Microsoft.Extensions.Options; |
| | 4 | |
|
| | 5 | | namespace Fluorite.Strainer.AspNetCore.Services; |
| | 6 | |
|
| | 7 | | /// <summary> |
| | 8 | | /// Provides access to <see cref="StrainerOptions"/> when using Strainer |
| | 9 | | /// within ASP.NET Core applications. |
| | 10 | | /// </summary> |
| | 11 | | public class AspNetCoreStrainerOptionsProvider : IStrainerOptionsProvider |
| | 12 | | { |
| | 13 | | private readonly IOptionsSnapshot<StrainerOptions> _options; |
| | 14 | |
|
| | 15 | | /// <summary> |
| | 16 | | /// Initializes a new instance of the <see cref="AspNetCoreStrainerOptionsProvider"/> |
| | 17 | | /// class. |
| | 18 | | /// </summary> |
| | 19 | | /// <param name="options"> |
| | 20 | | /// The Strainer options wrapper in <see cref="IOptionsSnapshot{TOptions}"/>. |
| | 21 | | /// </param> |
| | 22 | | /// <exception cref="ArgumentNullException"> |
| | 23 | | /// <paramref name="options"/> is <see langword="null"/>. |
| | 24 | | /// </exception> |
| 20 | 25 | | public AspNetCoreStrainerOptionsProvider(IOptionsSnapshot<StrainerOptions> options) |
| | 26 | | { |
| 20 | 27 | | _options = Guard.Against.Null(options); |
| 20 | 28 | | } |
| | 29 | |
|
| | 30 | | /// <inheritdoc/> |
| 16 | 31 | | public StrainerOptions GetStrainerOptions() => _options.Value; |
| | 32 | | } |