| | | 1 | | using ZhEaIsNsAaBn.Infrastructure.Core; |
| | | 2 | | |
| | | 3 | | // ReSharper disable once CheckNamespace |
| | | 4 | | namespace Microsoft.Extensions.DependencyInjection; |
| | | 5 | | |
| | | 6 | | /// <summary>Entry points for registering the infrastructure.</summary> |
| | | 7 | | public static class InfrastructureRegistration |
| | | 8 | | { |
| | | 9 | | /// <summary>Starts a fluent registration; call <see cref="IInfrastructureBuilder.Build"/> at the end.</summary> |
| | | 10 | | /// <param name="services">The service collection.</param> |
| | | 11 | | /// <returns>The builder.</returns> |
| | | 12 | | /// <exception cref="ArgumentNullException"><paramref name="services"/> is <see langword="null"/>.</exception> |
| | | 13 | | /// <example><code>services.AddInfrastructureCore().WithDbContext<AppDbContext>( o => o.UseSqlServer( cs ) |
| | 128 | 14 | | public static IInfrastructureBuilder AddInfrastructureCore( this IServiceCollection services ) => new Infrastructure |
| | | 15 | | |
| | | 16 | | /// <summary>Configures the registration in <paramref name="configure"/>, then builds it.</summary> |
| | | 17 | | /// <param name="services">The service collection.</param> |
| | | 18 | | /// <param name="configure">Records the registrations.</param> |
| | | 19 | | /// <returns>The service collection.</returns> |
| | | 20 | | /// <exception cref="ArgumentNullException">An argument is <see langword="null"/>.</exception> |
| | | 21 | | public static IServiceCollection AddInfrastructureCore( this IServiceCollection services, Action<IInfrastructureBuil |
| | | 22 | | { |
| | 4 | 23 | | ArgumentNullException.ThrowIfNull( configure ); |
| | | 24 | | |
| | 4 | 25 | | var builder = new InfrastructureBuilder( services ); |
| | | 26 | | |
| | | 27 | | |
| | 4 | 28 | | configure( builder ); |
| | | 29 | | |
| | 4 | 30 | | return builder.Build(); |
| | | 31 | | } |
| | | 32 | | } |