using adas_core.LdapLogin.Configuration;
using FluentValidation;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace adas_core.LdapLogin.RegistrationExtension;

/// <summary>
/// Extension class for registering LDAP authentication services and configurations in the service collection.
/// </summary>
public static class LdapRegistration
{
    /// <summary>
    /// Registers LDAP authentication services and configurations in the service collection using the provided configuration.
    /// </summary>
    /// <param name="serviceCollection">The service collection to which LDAP services will be added.</param>
    /// <param name="configuration">The configuration from which LDAP settings will be read.</param>
    public static void AddLdapAuth(this IServiceCollection serviceCollection, IConfigurationRoot configuration)
    {
        serviceCollection.AddSingleton<IValidator<LdapConfig>, LdapConfigValidator>();
        LdapModule.Configure(serviceCollection, configuration);
    }
}