90 lines
4.5 KiB
C#
90 lines
4.5 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<IUserService, UserService>();
|
|
_services.AddScoped<IUserImageService, UserImageService>();
|
|
_services.AddScoped<IInitDbService, InitDbService>();
|
|
_services.AddScoped<ITunnelService, TunnelService>();
|
|
_services.AddScoped<ITunnelFlightService, TunnelFlightService>();
|
|
|
|
_services.AddScoped<IStatsService, StatsService>();
|
|
_services.AddScoped<IStatsByDzService, StatsByDzService>();
|
|
_services.AddScoped<IStatsByGearService, StatsByGearService>();
|
|
_services.AddScoped<IStatsByJumpTypeService, StatsByJumpTypeService>();
|
|
_services.AddScoped<IStatsByYearByJumpTypeService, StatsByYearByJumpTypeService>();
|
|
_services.AddScoped<IStatsByYearService, StatsByYearService>();
|
|
_services.AddScoped<IStatsForLastMonthByDzService, StatsForLastMonthByDzService>();
|
|
_services.AddScoped<IStatsForLastMonthByJumpTypeService, StatsForLastMonthByJumpTypeService>();
|
|
_services.AddScoped<IStatsForLastYearByDzService, StatsForLastYearByDzService>();
|
|
_services.AddScoped<IStatsForLastYearByJumpTypeService, StatsForLastYearByJumpTypeService>();
|
|
|
|
_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<ITunnelFlightRepository, TunnelFlightRepository>();
|
|
|
|
_services.AddScoped<IStatsByDzRepository, StatsByDzRepository>();
|
|
_services.AddScoped<IStatsByGearRepository, StatsByGearRepository>();
|
|
_services.AddScoped<IStatsByJumpTypeRepository, StatsByJumpTypeRepository>();
|
|
_services.AddScoped<IStatsByYearByJumpTypeRepository, StatsByYearByJumpTypeRepository>();
|
|
_services.AddScoped<IStatsByYearRepository, StatsByYearRepository>();
|
|
_services.AddScoped<IStatsForLastMonthByDzRepository, StatsForLastMonthByDzRepository>();
|
|
_services.AddScoped<IStatsForLastMonthByJumpTypeRepository, StatsForLastMonthByJumpTypeRepository>();
|
|
_services.AddScoped<IStatsForLastYearByDzRepository, StatsForLastYearByDzRepository>();
|
|
_services.AddScoped<IStatsForLastYearByJumpTypeRepository, StatsForLastYearByJumpTypeRepository>();
|
|
|
|
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
|
|
}
|
|
} |