using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using PARR.BLL;
using PARR.DAL;
using PARR.GeneratorTemplates.Services;
using PARR.GeneratorTemplates.Settings;

namespace PARR.GeneratorTemplates
{
    public static class GeneratorTemplateInstaller
    {
        //1
        public static void InstallGeneratorTemplateServices(this IServiceCollection services, IConfiguration configuration)
        {
            services.InstallDalServices(configuration);
            services.InstallBllServices(configuration);

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

            //add other services
            services.AddTransient<IGeneratorTemplate, GeneratorTemplate>();
            services.AddTransient<IValidatorService, ValidatorService>();
            services.AddTransient<ITemplateManager, TemplateManager>();
        }

        //2
        public static IConfigurationBuilder AddGeneratorTemplateConfigurations(this IConfigurationBuilder builder, IServiceCollection services)
        {
            builder.AddDalConfigurations(services);

            return builder;
        }

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


    }
}
