Files
parr_api/PARR.TemplateMatcher/TemplateMatcherInstaller.cs

58 lines
2.7 KiB
C#

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using PARR.Core;
using PARR.DAL;
using PARR.Infrastructure;
using PARR.TemplateMatcher.Services.Implementations;
using PARR.TemplateMatcher.Services.Implemetaions;
using PARR.TemplateMatcher.Services.Interfaces;
using PARR.TemplateMatcher.Settings;
namespace PARR.TemplateMatcher
{
public static class TemplateMatcherInstaller
{
public static void InstallTemplateMatcherSerivces(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);
var templateSettings = new TemplateSettings();
configuration.GetSection(nameof(TemplateSettings)).Bind(templateSettings);
services.AddSingleton(templateSettings);
services.AddTransient<IMqTemplateMatcher, MqTemplateMatcher>();
services.AddTransient<IJobValidatorService, JobValidatorService>();
services.AddTransient<IJobGroupValidatorService, JobGroupValidatorService>();
services.AddTransient<ITemplateMatcher, TemplateMatcher>();
services.AddTransient<ITemplateReuser, TemplateReuser>();
services.AddTransient<ITemplateNameNormalizer, TemplateNameNormalizer>();
services.AddTransient<ITemplateUpdaterMqSender, TemplateUpdaterMqSender>();
services.AddTransient<ITemplateDeactivator, TemplateDeactivator>();
services.AddTransient<IUnitInTemplateConflictMapper, UnitInTemplateConflictMapper>();
services.AddTransient<IGroupedTemplateUnitFilter, GroupedTemplateUnitFilter>();
services.AddTransient<IGroupedTemplateBuilder, GroupedTemplateBuilder>();
services.AddTransient<IGroupedTemplateProcessor, GroupedTemplateProcessor>();
services.AddTransient<ITemplateSynchronizer, SimpleTemplateSynchronizer>();
services.AddTransient<ITemplateSynchronizer, GroupedTemplateSynchronizer>();
}
public static IConfigurationBuilder AddTemplateMatcherConfigurations(this IConfigurationBuilder builder, IServiceCollection services)
{
builder.AddDalConfigurations(services);
return builder;
}
public static void AddTemplateMatcherSettings(this IServiceCollection services, IConfiguration configuration)
{
services.AddDallSettings(configuration);
}
}
}