29 lines
809 B
C#
29 lines
809 B
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using NetDaemon.AppModel;
|
|
using LeakMonitorManager.Interface;
|
|
using LeakMonitorManager.Models;
|
|
|
|
namespace LeakMonitorManager;
|
|
|
|
public static class LeakMonitorServiceRegistration
|
|
{
|
|
public static IServiceCollection AddLeakMonitor(this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
var options = configuration
|
|
.GetSection(LeakMonitorOptions.SectionName)
|
|
.Get<LeakMonitorOptions>() ?? new LeakMonitorOptions();
|
|
|
|
if (!options.Enabled)
|
|
{
|
|
return services;
|
|
}
|
|
|
|
services
|
|
.AddNetDaemonApp<LeakMonitorInit>()
|
|
.AddScoped<ILeakNotificationService, LeakNotificationService>();
|
|
|
|
return services;
|
|
}
|
|
}
|