persistence/Persistence.Repository/DependencyInjection.cs

40 lines
1.4 KiB
C#
Raw Normal View History

using Mapster;
using Microsoft.Extensions.DependencyInjection;
using Persistence.Database.Model;
2024-11-26 10:32:44 +05:00
using Persistence.Models;
using Persistence.Repositories;
using Persistence.Repository.Data;
using Persistence.Repository.Repositories;
namespace Persistence.Repository;
public static class DependencyInjection
{
public static void MapsterSetup()
{
TypeAdapterConfig.GlobalSettings.Default.Config
.ForType<ChangeLog, ChangeLogDto>()
.Map(dest => dest.Value, src => new DataWithWellDepthAndSectionDto()
{
DepthEnd = src.DepthEnd,
DepthStart = src.DepthStart,
IdSection = src.IdSection,
Value = src.Value,
Id = src.Id
});
}
public static IServiceCollection AddInfrastructure(this IServiceCollection services)
{
MapsterSetup();
services.AddTransient<ITimeSeriesDataRepository<DataSaubDto>, TimeSeriesDataRepository<DataSaub, DataSaubDto>>();
services.AddTransient<ISetpointRepository, SetpointRepository>();
services.AddTransient<ITimeSeriesDataRepository<DataSaubDto>, TimeSeriesDataCachedRepository<DataSaub, DataSaubDto>>();
services.AddTransient<IChangeLogRepository, ChangeLogRepository>();
2024-11-22 17:52:15 +05:00
services.AddTransient<ITimestampedSetRepository, TimestampedSetRepository>();
return services;
}
}