Files
SkydiveLogs/Back/skydiveLogs-api.Ioc/IocService.cs
2023-06-12 16:02:48 +02:00

70 lines
2.9 KiB
C#

using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using skydiveLogs_api.DomainBusiness;
using skydiveLogs_api.DomainBusiness.Interfaces;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Security.Claims;
namespace skydiveLogs_api.Ioc
{
public class IocService
{
#region Public Constructors
public IocService(IServiceCollection services,
IConfiguration configuration)
{
_services = services;
_configuration = configuration;
}
#endregion Public Constructors
#region Public Methods
public void Configure()
{
_services.AddScoped<IAircraftService, AircraftService>();
_services.AddScoped<IGearService, GearService>();
_services.AddScoped<IDropZoneService, DropZoneService>();
_services.AddScoped<IJumpService, JumpService>();
_services.AddScoped<IJumpTypeService, JumpTypeService>();
_services.AddScoped<IStatsService, StatsService>();
_services.AddScoped<IUserService, UserService>();
_services.AddScoped<IUserImageService, UserImageService>();
_services.AddScoped<IInitDbService, InitDbService>();
_services.AddScoped<ITunnelService, TunnelService>();
_services.AddScoped<ITunnelFlightService, TunnelFlightService>();
_services.AddSingleton<ICacheService, CacheService>();
_services.AddScoped<IIdentityService, IdentityService>();
_services.AddScoped<ClaimsPrincipal>(s => s.GetService<IHttpContextAccessor>()?.HttpContext.User);
_services.AddScoped<IAircraftRepository, AircraftRepository>();
_services.AddScoped<IDropZoneRepository, DropZoneRepository>();
_services.AddScoped<IJumpRepository, JumpRepository>();
_services.AddScoped<IJumpTypeRepository, JumpTypeRepository>();
_services.AddScoped<IGearRepository, GearRepository>();
_services.AddScoped<IUserRepository, UserRepository>();
_services.AddScoped<IUserImageRepository, UserImageRepository>();
_services.AddScoped<IFavoriteDropZoneRepository, FavoriteDropZoneRepository>();
_services.AddScoped<IUserStatsRepository, UserStatsRepository>();
_services.AddScoped<ITunnelFlightRepository, TunnelFlightRepository>();
string connectionString = _configuration.GetConnectionString("DefaultConnection");
_services.AddSingleton<IDataProvider>(c => new LiteDbProvider(connectionString));
}
#endregion Public Methods
#region Private Fields
private readonly IConfiguration _configuration;
private readonly IServiceCollection _services;
#endregion Private Fields
}
}