using Microsoft.Extensions.Options;

namespace ZB.MOM.WW.MxGateway.Server.Configuration;

public static class GatewayConfigurationServiceCollectionExtensions
{
    /// <summary>Registers gateway configuration services in the dependency injection container.</summary>
    /// <param name="services">The service collection.</param>
    /// <returns>The service collection for chaining.</returns>
    public static IServiceCollection AddGatewayConfiguration(this IServiceCollection services)
    {
        services
            .AddOptions<GatewayOptions>()
            .BindConfiguration(GatewayOptions.SectionName)
            .ValidateOnStart();

        services.AddSingleton<IValidateOptions<GatewayOptions>, GatewayOptionsValidator>();
        services.AddSingleton<IGatewayConfigurationProvider, GatewayConfigurationProvider>();

        return services;
    }
}
