using HRD.LDAPService.JWT;
using HRD.LDAPService.Ldap;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;

namespace HRD.LDAPService
{
    public static class DIExtensions
    {
        private static IServiceCollection AddJwtManagerWithLdap(this IServiceCollection services)
        {
            services
                .AddSingleton<LdapAuthenticationService>()
                .AddSingleton<JwtManager>()
                .AddSingleton<LdapManager>();
                
            return services;
        }

        public static IServiceCollection AddJwtManagerWithLdap(this IServiceCollection services, Action<LdapOptions> configureOptions) 
            => services
                .Configure(configureOptions)
                .AddJwtManagerWithLdap();

        public static IServiceCollection AddJwtManagerWithLdap(this IServiceCollection services, IConfiguration configuration)
            => services
                .Configure<LdapOptions>(configuration)
                .AddJwtManagerWithLdap();
    }
}