27 lines
983 B
C#
27 lines
983 B
C#
|
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||
|
|
using SurveillanceClient.Core.Configuration;
|
||
|
|
using SurveillanceClient.Core.Services;
|
||
|
|
|
||
|
|
namespace SurveillanceClient.Core;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// DI registration helpers for the SurveillanceClient Core services.
|
||
|
|
/// </summary>
|
||
|
|
public static class ServiceCollectionExtensions
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// Registers <see cref="IRsNetClient"/> and binds its options from
|
||
|
|
/// configuration. The client is a singleton because <c>RSNet.dll</c>
|
||
|
|
/// holds process-wide global state.
|
||
|
|
/// </summary>
|
||
|
|
public static IServiceCollection AddSurveillanceClientCore(this IServiceCollection services)
|
||
|
|
{
|
||
|
|
services.AddOptions<RsNetOptions>().BindConfiguration(RsNetOptions.SectionName);
|
||
|
|
services.AddOptions<DeviceOptions>().BindConfiguration(DeviceOptions.SectionName);
|
||
|
|
|
||
|
|
services.TryAddSingleton<IRsNetClient, RsNetClient>();
|
||
|
|
|
||
|
|
return services;
|
||
|
|
}
|
||
|
|
}
|