Migrate existing code
This commit is contained in:
parent
384ff4a6f3
commit
9b49f880a2
30 changed files with 1789 additions and 5 deletions
26
Services/Dhcp/DhcpWatcherFactoryServices.cs
Normal file
26
Services/Dhcp/DhcpWatcherFactoryServices.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using DotNetDDI.Integrations.Kea;
|
||||
using DotNetDDI.Options;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace DotNetDDI.Services.Dhcp;
|
||||
|
||||
public static class DhcpWatcherFactoryServices
|
||||
{
|
||||
public static IServiceCollection AddDhcpWatcherFactory(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IDhcpWatcherFactory, DhcpWatcherFactory>();
|
||||
return services;
|
||||
}
|
||||
|
||||
private class DhcpWatcherFactory(IServiceProvider services) : IDhcpWatcherFactory
|
||||
{
|
||||
private ObjectFactory<KeaService>? _cachedKeaService;
|
||||
|
||||
KeaService IDhcpWatcherFactory.KeaService(KeaDhcpOptions options)
|
||||
{
|
||||
_cachedKeaService ??= ActivatorUtilities.CreateFactory<KeaService>([typeof(KeaDhcpOptions)]);
|
||||
return _cachedKeaService(services, [options]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue