44 lines
1.6 KiB
C#
44 lines
1.6 KiB
C#
using DD.Persistence.Client.Clients;
|
|
using DD.Persistence.Client.Clients.Interfaces;
|
|
using DD.Persistence.Client.Clients.Mapping;
|
|
using DD.Persistence.Models;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace DD.Persistence.Client;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public static class DependencyInjection
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <returns></returns>
|
|
public static IServiceCollection AddPersistenceClients(this IServiceCollection services, Dictionary<Guid, Type>? setpointTypeConfigs = null)
|
|
{
|
|
services.AddTransient(typeof(IRefitClientFactory<>), typeof(RefitClientFactory<>));
|
|
services.AddTransient<IChangeLogClient, ChangeLogClient>();
|
|
services.AddTransient<IDataSourceSystemClient, DataSourceSystemClient>();
|
|
services.AddTransient<ISetpointClient, SetpointClient>();
|
|
services.AddTransient<ITechMessagesClient, TechMessagesClient>();
|
|
services.AddTransient<ITimestampedValuesClient, TimestampedValuesClient>();
|
|
services.AddTransient<IWitsDataClient, WitsDataClient>();
|
|
|
|
return services;
|
|
}
|
|
|
|
|
|
public static IServiceCollection AddPersistenceMapping(this IServiceCollection services, Dictionary<Guid, Type>? mappingConfigs)
|
|
{
|
|
services.AddTransient<ISetpointMappingClient, SetpointMappingClient>(provider =>
|
|
{
|
|
var client = provider.GetRequiredService<ISetpointClient>();
|
|
return new SetpointMappingClient(client, mappingConfigs);
|
|
});
|
|
services.AddTransient<ITimestampedMappingClient, TimestampedMappingClient>();
|
|
return services;
|
|
}
|
|
}
|