| | | 1 | | using ZhEaIsNsAaBn.Infrastructure.Specifications; |
| | | 2 | | |
| | | 3 | | // ReSharper disable once CheckNamespace |
| | | 4 | | namespace Microsoft.Extensions.DependencyInjection; |
| | | 5 | | |
| | | 6 | | /// <summary>Registers the specification infrastructure.</summary> |
| | | 7 | | public static class SpecificationServiceRegistration |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// Registers <typeparamref name="TDbContext"/> as a pooled factory (Core <c>AsFactoryPool</c>), the specification u |
| | | 11 | | /// the open-generic specification repositories. |
| | | 12 | | /// </summary> |
| | | 13 | | /// <typeparam name="TDbContext">The application's context.</typeparam> |
| | | 14 | | /// <param name="services">The service collection.</param> |
| | | 15 | | /// <param name="dbContextOptionsBuilder">Configures the context, e.g. <c>o => o.UseSqlServer( connectionString ) |
| | | 16 | | /// <param name="poolSize">The maximum number of pooled contexts.</param> |
| | | 17 | | /// <returns>The service collection.</returns> |
| | | 18 | | public static IServiceCollection AddSpecificationService< TDbContext >( this IServiceCollection services, Action<DbC |
| | | 19 | | where TDbContext : DbContext |
| | | 20 | | { |
| | 8 | 21 | | services.AddInfrastructureCore().WithDbContext<TDbContext>( dbContextOptionsBuilder ).AsFactoryPool( poolSize ). |
| | 8 | 22 | | services.AddTransient<ISpecificationUnitOfWork<TDbContext>, SpecificationUnitOfWork<TDbContext>>(); |
| | 8 | 23 | | services.AddTransient( typeof( ISpecificationRepository<,,> ), typeof( SpecificationRepository<,,> ) ); |
| | 8 | 24 | | services.AddTransient( typeof( ISpecificationIntRepository<,> ), typeof( SpecificationRepository<,> ) ); |
| | | 25 | | |
| | 8 | 26 | | return services; |
| | | 27 | | } |
| | | 28 | | } |