using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using PARR.Core;
using PARR.DAL;
using PARR.Infrastructure;

namespace PARR.TemplateActivator;

public static class TemplateActivatorInstaller
{

    public static void InstallTemplateActivatorSerivces(this IServiceCollection services, IConfiguration configuration)
    {
        services.AddDalServices(configuration);
        services.AddCoreServices(configuration);
        services.AddInfrastructureServices(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);
    }
}
