38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
|
using Microsoft.Extensions.Configuration;
|
|||
|
using Microsoft.Extensions.DependencyInjection;
|
|||
|
using NetworkResurrector.WakeOnLan.Inhouse;
|
|||
|
using NetworkResurrector.WakeOnLan.Nikeee;
|
|||
|
using System;
|
|||
|
|
|||
|
namespace NetworkResurrector.Server.Extensions
|
|||
|
{
|
|||
|
public static class WakeOnLanExtensions
|
|||
|
{
|
|||
|
private struct WolProvider
|
|||
|
{
|
|||
|
public const string
|
|||
|
Inhouse = "Inhouse",
|
|||
|
Nikeee = "Nikeee";
|
|||
|
}
|
|||
|
|
|||
|
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.");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|