| | | 1 | | using AsiBackbone.Core.CapabilityGrants; |
| | | 2 | | using Microsoft.EntityFrameworkCore; |
| | | 3 | | using Microsoft.Extensions.DependencyInjection; |
| | | 4 | | |
| | | 5 | | namespace AsiBackbone.EntityFrameworkCore.CapabilityGrants; |
| | | 6 | | |
| | | 7 | | /// <summary>Registers durable EF Core capability-grant replay protection.</summary> |
| | | 8 | | public static class EfCoreCapabilityGrantUseStoreServiceCollectionExtensions |
| | | 9 | | { |
| | | 10 | | /// <summary>Registers the durable store against a host-owned context.</summary> |
| | | 11 | | public static IServiceCollection AddAsiBackboneEfCoreCapabilityGrantUseStore<TDbContext>( |
| | | 12 | | this IServiceCollection services, |
| | | 13 | | Action<EfCoreCapabilityGrantUseStoreOptions>? configure = null) |
| | | 14 | | where TDbContext : DbContext |
| | | 15 | | { |
| | 0 | 16 | | ArgumentNullException.ThrowIfNull(services); |
| | 0 | 17 | | EfCoreCapabilityGrantUseStoreOptions options = new(); |
| | 0 | 18 | | configure?.Invoke(options); |
| | 0 | 19 | | options.Validate(); |
| | 0 | 20 | | _ = services.AddSingleton(options); |
| | 0 | 21 | | _ = services.AddScoped<EfCoreCapabilityGrantUseStore>(provider => |
| | 0 | 22 | | new(provider.GetRequiredService<TDbContext>(), provider.GetRequiredService<EfCoreCapabilityGrantUseStoreOpti |
| | 0 | 23 | | _ = services.AddScoped<ICapabilityGrantUseStore>(provider => |
| | 0 | 24 | | provider.GetRequiredService<EfCoreCapabilityGrantUseStore>()); |
| | 0 | 25 | | return services; |
| | | 26 | | } |
| | | 27 | | } |