generated from nventive/Template
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathKillSwitchService.cs
More file actions
36 lines (32 loc) · 1.14 KB
/
KillSwitchService.cs
File metadata and controls
36 lines (32 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Reactive.Linq;
using ApplicationTemplate.DataAccess;
using Microsoft.Extensions.Logging;
namespace ApplicationTemplate.Business;
/// <summary>
/// Implementation of the IKillSwitchService.
/// </summary>
public sealed class KillSwitchService : IKillSwitchService
{
private readonly IKillSwitchDataSource _killSwitchDataSource;
private readonly ILogger<KillSwitchService> _logger;
/// <summary>
/// Initializes a new instance of the <see cref="KillSwitchService"/> class.
/// </summary>
/// <param name="killSwitchDataSource">The <see cref="IKillSwitchDataSource"/>.</param>
/// <param name="logger">The <see cref="ILogger{KillSwitchService}"/>.</param>
public KillSwitchService(IKillSwitchDataSource killSwitchDataSource, ILogger<KillSwitchService> logger)
{
_killSwitchDataSource = killSwitchDataSource;
_logger = logger;
}
/// <inheritdoc/>
public IObservable<bool> ObserveKillSwitchActivation() => _killSwitchDataSource.ObserveKillSwitchActivation()
.Do(isActive =>
{
if (_logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation("Kill switch is now {IsActive}.", isActive);
}
});
}