24729ee267
- Reindent appsettings.json and the MSBuild project files - Collapse single-statement guard blocks and tidy using and member order - Normalize XML doc indentation and file endings - Reorder BatteryMonitor test-data helpers and move the exclusion tests into their own region - Carry the same formatting through the boiler config, control, entity and test files
28 lines
1.0 KiB
C#
28 lines
1.0 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using NetDaemon.AppModel;
|
|
using ShowerMonitorManager.Interface;
|
|
using ShowerMonitorManager.Models;
|
|
|
|
namespace ShowerMonitorManager;
|
|
|
|
public static class ShowerMonitorServiceRegistration
|
|
{
|
|
public static IServiceCollection AddShowerMonitor(this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
var options = configuration
|
|
.GetSection(ShowerMonitorOptions.SectionName)
|
|
.Get<ShowerMonitorOptions>() ?? new ShowerMonitorOptions();
|
|
|
|
if (!options.Enabled) return services;
|
|
|
|
services
|
|
.AddNetDaemonApp<ShowerMonitorInit>()
|
|
.AddSingleton<IHumidityRateCalculator>(_ => new HumidityRateCalculator(options.RateWindowSize))
|
|
.AddSingleton<IShowerDetectionService, ShowerDetectionService>()
|
|
.AddScoped<IExhaustFanControlService, ExhaustFanControlService>()
|
|
.AddTransient<IShowerMonitorEntityService, ShowerMonitorEntityService>();
|
|
|
|
return services;
|
|
}
|
|
} |