Use NetworkResurrector.WakeOnLan.Nikeee
parent
df24fea9e0
commit
1fcd2afdc5
|
@ -1,14 +1,37 @@
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NetworkResurrector.WakeOnLan.Inhouse;
|
||||
using NetworkResurrector.WakeOnLan.Nikeee;
|
||||
using System;
|
||||
|
||||
namespace NetworkResurrector.Api.Extensions
|
||||
{
|
||||
public static class WakeOnLanExtensions
|
||||
{
|
||||
private struct WolProvider
|
||||
{
|
||||
public const string
|
||||
Inhouse = "Inhouse",
|
||||
Nikeee = "Nikeee";
|
||||
}
|
||||
|
||||
public static void AddWakeOnLan(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddWakeOnLanService();
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\NetworkResurrector.Application\NetworkResurrector.Application.csproj" />
|
||||
<ProjectReference Include="..\NetworkResurrector.WakeOnLan.Inhouse\NetworkResurrector.WakeOnLan.Inhouse.csproj" />
|
||||
<ProjectReference Include="..\NetworkResurrector.WakeOnLan.Nikeee\NetworkResurrector.WakeOnLan.Nikeee.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -17,5 +17,11 @@
|
|||
"UserName": "***REMOVED***",
|
||||
"Password": "***REMOVED***"
|
||||
}
|
||||
]
|
||||
],
|
||||
"WakeOnLan": {
|
||||
"Provider": {
|
||||
"Use": "Inhouse",
|
||||
"Options": [ "Inhouse", "Nikeee" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace NetworkResurrector.WakeOnLan.Inhouse
|
|||
{
|
||||
public static class DependencyInjectionExtensions
|
||||
{
|
||||
public static void AddWakeOnLanService(this IServiceCollection services)
|
||||
public static void AddWakeOnLanInhouseService(this IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<WolClient>();
|
||||
services.AddScoped<IWakeOnLanService, WolDriver>();
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace NetworkResurrector.WakeOnLan.Nikeee
|
|||
{
|
||||
public static class DependencyInjectionExtensions
|
||||
{
|
||||
public static void AddWakeOnLanService(this IServiceCollection services)
|
||||
public static void AddWakeOnLanNikeeeService(this IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<IWakeOnLanService, WakeOnLanService>();
|
||||
}
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
using NetworkResurrector.Abstractions;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetworkResurrector.WakeOnLan.Nikeee
|
||||
{
|
||||
public class WakeOnLanService : IWakeOnLanService
|
||||
{
|
||||
public Task<(bool success, string message)> Wake(string macAddress)
|
||||
public async Task<(bool success, string message)> Wake(string macAddress)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var mac = PhysicalAddress.Parse(macAddress);
|
||||
await mac.SendWolAsync();
|
||||
|
||||
return (true, "Success");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue