using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using PARR.BLL;
using PARR.DAL;

namespace PARR.TemplateActivator;

public static class TemplateActivatorInstaller
{

    public static void InstallTemplateActivatorSerivces(this IServiceCollection services, IConfiguration configuration)
    {
        services.InstallBllServices(configuration);
        services.InstallDalServices(configuration);

        var mqSettings = new MqSettings();
        configuration.GetSection(nameof(MqSettings)).Bind(mqSettings);
        services.AddSingleton(mqSettings);

        services.AddTransient<ITemplateActivator, TemplateActivator>();
        services.AddTransient<IMqTemplateActivator, MqTemplateActivator>();
        services.AddTransient<IValidatorService, ValidatorService>();
    }

    public static IConfigurationBuilder AddTemplateActivatorConfigurations(this IConfigurationBuilder builder, IServiceCollection services)
    {
        builder.AddDalConfigurations(services);

        return builder;
    }

    public static void AddTemplateActivatorSettings(this IServiceCollection services, IConfiguration configuration)
    {
        services.AddDallSettings(configuration);
    }
}
