Files
lux/EgwCoreLib.Lux.Data/DataServiceCollectionExtensions.cs
2026-03-24 12:55:16 +01:00

120 lines
7.0 KiB
C#

using EgwCoreLib.Lux.Data.Repository.Config;
using EgwCoreLib.Lux.Data.Repository.Cost;
using EgwCoreLib.Lux.Data.Repository.Items;
using EgwCoreLib.Lux.Data.Repository.Job;
using EgwCoreLib.Lux.Data.Repository.Production;
using EgwCoreLib.Lux.Data.Repository.Sales;
using EgwCoreLib.Lux.Data.Repository.Stats;
using EgwCoreLib.Lux.Data.Repository.Utils;
using EgwCoreLib.Lux.Data.Services.Config;
using EgwCoreLib.Lux.Data.Services.Cost;
using EgwCoreLib.Lux.Data.Services.General;
using EgwCoreLib.Lux.Data.Services.Internal;
using EgwCoreLib.Lux.Data.Services.Items;
using EgwCoreLib.Lux.Data.Services.Job;
using EgwCoreLib.Lux.Data.Services.Production;
using EgwCoreLib.Lux.Data.Services.Sales;
using EgwCoreLib.Lux.Data.Services.Stats;
using EgwCoreLib.Lux.Data.Services.Utils;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace EgwCoreLib.Lux.Data
{
public static class DataServiceCollectionExtensions
{
public static IServiceCollection AddLuxData(this IServiceCollection services, string connectionString)
{
//// DbContextFactory: preferibile in Blazor Server e scenari concorrenti
//services.AddDbContextFactory<DataLayerContext>(options =>
// options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
// servizi preliminari
//services.TryAddSingleton<IConnectionMultiplexer>(redisConn);
services.TryAddSingleton<IRedisService, RedisService>();
services.TryAddSingleton<RedisSubscriptionManager>();
// Repository Scoped
services.TryAddScoped<IConfGlassRepository, ConfGlassRepository>();
services.TryAddScoped<IConfProfileRepository, ConfProfileRepository>();
services.TryAddScoped<IConfWoodRepository, ConfWoodRepository>();
services.TryAddScoped<ICostDriverRepository, CostDriverRepository>();
services.TryAddScoped<ICustomerRepository, CustomerRepository>();
services.TryAddScoped<IDealerRepository, DealerRepository>();
services.TryAddScoped<IEnvirParamRepository, EnvirParamRepository>();
services.TryAddScoped<IGenClassRepository, GenClassRepository>();
services.TryAddScoped<IGenValRepository, GenValRepository>();
services.TryAddScoped<IItemGroupRepository, ItemGroupRepository>();
services.TryAddScoped<IItemRepository, ItemRepository>();
services.TryAddScoped<IJobStepRepository, JobStepRepository>();
services.TryAddScoped<IJobTaskRepository, JobTaskRepository>();
services.TryAddScoped<IOfferRepository, OfferRepository>();
services.TryAddScoped<IOfferRowRepository, OfferRowRepository>();
services.TryAddScoped<IOrderRepository, OrderRepository>();
services.TryAddScoped<IOrderRowRepository, OrderRowRepository>();
services.TryAddScoped<IPhaseRepository, PhaseRepository>();
services.TryAddScoped<IProductionBatchRepository, ProductionBatchRepository>();
services.TryAddScoped<IProductionGroupRepository, ProductionGroupRepository>();
services.TryAddScoped<IProductionItemRepository, ProductionItemRepository>();
services.TryAddScoped<IProductionOdlRepository, ProductionOdlRepository>();
services.TryAddScoped<IProductionPlantRepository, ProductionPlantRepository>();
services.TryAddScoped<IResourceRepository, ResourceRepository>();
services.TryAddScoped<ISellingItemRepository, SellingItemRepository>();
services.TryAddScoped<IStatsAggrRepository, StatsAggrRepository>();
services.TryAddScoped<IStatsDetailRepository, StatsDetailRepository>();
services.TryAddScoped<ITagRepository, TagRepository>();
services.TryAddScoped<ITemplateRepository, TemplateRepository>();
services.TryAddScoped<ITemplateRowRepository, TemplateRowRepository>();
// Servizi Scoped
services.TryAddScoped<IConfGlassService, ConfGlassService>();
services.TryAddScoped<IConfProfileService, ConfProfileService>();
services.TryAddScoped<IConfWoodService, ConfWoodService>();
services.TryAddScoped<ICostDriverService, CostDriverService>();
services.TryAddScoped<ICustomerService, CustomerService>();
services.TryAddScoped<IDealerService, DealerService>();
services.TryAddScoped<IEnvirParamService, EnvirParamService>();
services.TryAddScoped<IGenClassService, GenClassService>();
services.TryAddScoped<IGenValService, GenValService>();
services.TryAddScoped<IItemService, ItemService>();
services.TryAddScoped<IItemGroupService, ItemGroupService>();
services.TryAddScoped<IJobStepService, JobStepService>();
services.TryAddScoped<IJobTaskService, JobTaskService>();
services.TryAddScoped<IOfferService, OfferService>();
services.TryAddScoped<IOfferRowService, OfferRowService>();
services.TryAddScoped<IOrderService, OrderService>();
services.TryAddScoped<IOrderRowService, OrderRowService>();
services.TryAddScoped<IPhaseService, PhaseService>();
services.TryAddScoped<IProductionGroupService, ProductionGroupService>();
services.TryAddScoped<IProductionItemService, ProductionItemService>();
services.TryAddScoped<IProductionBatchService, ProductionBatchService>();
services.TryAddScoped<IProductionOdlService, ProductionOdlService>();
services.TryAddScoped<IProductionPlantService, ProductionPlantService>();
services.TryAddScoped<IResourceService, ResourceService>();
services.TryAddScoped<ISellingItemService, SellingItemService>();
services.TryAddScoped<IStatsAggrService, StatsAggrService>();
services.TryAddScoped<IStatsDetailService, StatsDetailService>();
services.TryAddScoped<ITagService, TagService>();
services.TryAddScoped<ITemplateService, TemplateService>();
services.TryAddScoped<ITemplateRowService, TemplateRowService>();
// Facade / DataLayerService
services.TryAddScoped<IDataLayerServices, DataLayerServices>();
services.TryAddScoped<ICalcRuidService, CalcRuidService>();
//builder.Services.AddSingleton<DataLayerServices>();
//services.TryAddScoped<IDataLayerServices, DataLayerServices>();
// aggiunta servizi finali Singleton...
services.TryAddSingleton<IImageCacheService, ImageCacheService>();
services.TryAddSingleton<IConfigDataService, ConfigDataService>();
services.TryAddSingleton<ICalcRequestService, CalcRequestService>();
services.TryAddSingleton<IFileService, FileService>();
services.TryAddSingleton<IProdService, ProdService>();
//services.TryAddSingleton<CalcRequestService>();
return services;
}
}
}