using Autofac;
using e_suite.DependencyInjection;
using eSuite.API.SingleSignOn;
using eSuite.API.Translation;

namespace eSuite.API.DependencyInjection;

/// <summary>
/// Used as the primary location for IOC type registration for e-suite.
/// </summary>
internal class CoreRegistrationModule : ESuiteModule
{
    /// <summary>
    /// Use the builder to register all the types and interfaces that the API requires to operate properly.
    /// </summary>
    /// <param name="builder"></param>
    protected override void Load(ContainerBuilder builder)
    {
        base.Load(builder);

        //builder.RegisterType<UtcClock>().As<IClock>().SingleInstance();
        builder.RegisterType<SingleSignOn.SingleSignOn>().As<ISingleSignOn>();
        builder.RegisterType<CookieManager>().As<ICookieManager>();
        builder.RegisterType<HttpClientFacade>().As<IHttpClientFacade>();

        builder.RegisterType<JsonLocalizationService>()
            .As<IJsonLocalizationService>()
            .SingleInstance(); // safe to cache globally
        builder.RegisterType<TranslatorFactory>()
            .As<ITranslatorFactory>()
            .InstancePerLifetimeScope(); // per-request, because locale is per-request




        //e_suite.Service.Mail.IocRegistration.RegisterTypes(builder);
        //e_suite.Service.Sentinel.IocRegistration.RegisterTypes(builder);

        //e_suite.Modules.CustomFieldsManager.IocRegistration.RegisterTypes(builder);
        //e_suite.Service.CustomFieldValidation.IocRegistration.RegisterTypes(builder);
        //e_suite.Modules.FormsManager.IocRegistration.RegisterTypes(builder);
        //e_suite.Modules.GlossariesManager.IocRegistration.RegisterTypes(builder);
        //e_suite.Modules.OrganisationsManager.IocRegistration.RegisterTypes(builder);
        //e_suite.Modules.SequenceManager.IocRegistration.RegisterTypes(builder);
        //e_suite.Modules.UserManager.IocRegistration.RegisterTypes(builder);
        //e_suite.Modules.AuditLog.IocRegistration.RegisterTypes(builder);
        //e_suite.Modules.DomainManager.IocRegistration.RegisterTypes(builder);
        //e_suite.Modules.MailTemplatesManager.IocRegistration.RegisterTypes(builder);
        //e_suite.Modules.RoleManager.IocRegistration.RegisterTypes(builder);
        //e_suite.Modules.SiteManager.IocRegistration.RegisterTypes(builder);
        //e_suite.Modules.SpecificationManager.IocRegistration.RegisterTypes(builder);
        //e_suite.Modules.BlockedIPsManager.IocRegistration.RegisterTypes(builder);
        //e_suite.Modules.ExceptionLogManager.IocRegistration.RegisterTypes(builder);
        //e_suite.Modules.SSOManager.IocRegistration.RegisterTypes(builder);

        //e_suite.Messaging.Common.DependencyInjection.CoreRegistrationModule.Load(builder);
    }
}