network-resurrector/NetworkResurrector.Server/Extensions/WakeOnLanExtensions.cs

38 lines
1.1 KiB
C#
Raw Normal View History

2020-11-25 17:01:14 +02:00
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using NetworkResurrector.WakeOnLan.Inhouse;
using NetworkResurrector.WakeOnLan.Nikeee;
using System;
2020-11-25 17:01:14 +02:00
2021-04-06 02:12:58 +03:00
namespace NetworkResurrector.Server.Extensions
2020-11-25 17:01:14 +02:00
{
public static class WakeOnLanExtensions
{
private struct WolProvider
{
public const string
Inhouse = "Inhouse",
Nikeee = "Nikeee";
}
2020-11-25 17:01:14 +02:00
public static void AddWakeOnLan(this IServiceCollection services, IConfiguration configuration)
{
var wolProvider = configuration.GetSection("WakeOnLan").GetSection("Provider").GetValue<string>("Use");
switch (wolProvider)
{
case WolProvider.Inhouse:
services.AddWakeOnLanInhouseService();
break;
case WolProvider.Nikeee:
services.AddWakeOnLanNikeeeService();
break;
default:
throw new Exception($"Wake on LAN provider '{wolProvider}' is not implemented.");
}
2020-11-25 17:01:14 +02:00
}
}
}