Files
GreenHomeBack/src/GreenHome.Infrastructure/DependencyInjection.cs

75 lines
2.7 KiB
C#

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>();
services.AddScoped<AlertConditionEvaluator>();
services.AddScoped<AlertMessageBuilder>();
services.AddScoped<AlertNotificationSender>();
services.AddScoped<AlertPersistenceService>();
// 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;
}
}