using PARR.Core;
using PARR.DAL;
using PARR.Infrastructure;
using PARR.TemplateGeneratorWorker.Services;
using PARR.TemplateGeneratorWorker.Settings;

namespace PARR.TemplateGeneratorWorker
{
    public static class TemplateGeneratorWorkerInstaller
    {
        public static void InstallTemplateGeneratorWorkerSerivces(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<ITemplateGenerator, TemplateGenerator>();
            services.AddTransient<IValidatorService, ValidatorService>();
        }

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

            return builder;
        }

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