refactor: reorganize Infrastructure layer into folder structure with DI
This commit is contained in:
70
src/GreenHome.Infrastructure/DependencyInjection.cs
Normal file
70
src/GreenHome.Infrastructure/DependencyInjection.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using GreenHome.Application;
|
||||
using GreenHome.Infrastructure.Data;
|
||||
using GreenHome.Infrastructure.Services.AI;
|
||||
using GreenHome.Infrastructure.Services.Alert;
|
||||
using GreenHome.Infrastructure.Services.Auth;
|
||||
using GreenHome.Infrastructure.Services.Checklist;
|
||||
using GreenHome.Infrastructure.Services.Device;
|
||||
using GreenHome.Infrastructure.Services.PowerOutage;
|
||||
using GreenHome.Infrastructure.Services.Report;
|
||||
using GreenHome.Infrastructure.Services.Sun;
|
||||
using GreenHome.Infrastructure.Services.Telemetry;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace GreenHome.Infrastructure;
|
||||
|
||||
/// <summary>
|
||||
/// Registers all Infrastructure-layer services with the DI container.
|
||||
/// Call this from Program.cs to keep startup clean.
|
||||
/// </summary>
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public static IServiceCollection AddInfrastructure(
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
// Entity Framework
|
||||
services.AddDbContext<GreenHomeDbContext>(options =>
|
||||
{
|
||||
options.UseSqlServer(configuration.GetConnectionString("Default"));
|
||||
});
|
||||
|
||||
// Auth
|
||||
services.AddScoped<IAuthService, AuthService>();
|
||||
|
||||
// Alert
|
||||
services.AddScoped<IAlertService, AlertService>();
|
||||
services.AddScoped<IAlertConditionService, AlertConditionService>();
|
||||
services.AddScoped<IAlertLogService, AlertLogService>();
|
||||
|
||||
// Device
|
||||
services.AddScoped<IDeviceService, DeviceService>();
|
||||
services.AddScoped<IDeviceSettingsService, DeviceSettingsService>();
|
||||
services.AddScoped<IDeviceTokenService, DeviceTokenService>();
|
||||
services.AddScoped<IDevicePostService, DevicePostService>();
|
||||
|
||||
// Telemetry
|
||||
services.AddScoped<ITelemetryService, TelemetryService>();
|
||||
|
||||
// Reports
|
||||
services.AddScoped<IDailyReportService, DailyReportService>();
|
||||
services.AddScoped<IMonthlyReportService, MonthlyReportService>();
|
||||
services.AddScoped<IUserDailyReportService, UserDailyReportService>();
|
||||
|
||||
// Checklist
|
||||
services.AddScoped<IChecklistService, ChecklistService>();
|
||||
|
||||
// Power Outage
|
||||
services.AddScoped<IPowerOutageLogService, PowerOutageLogService>();
|
||||
|
||||
// AI
|
||||
services.AddScoped<IAIQueryService, AIQueryService>();
|
||||
|
||||
// Sun Calculator
|
||||
services.AddScoped<ISunCalculatorService, SunCalculatorService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user