generated from nventive/Template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7055a21
commit 7ba0cd5
Showing
4 changed files
with
50 additions
and
75 deletions.
There are no files selected for viewing
21 changes: 19 additions & 2 deletions
21
src/app/ApplicationTemplate.Business/KillSwitch/KillSwitchService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,42 @@ | ||
using System; | ||
using System.Reactive.Linq; | ||
using ApplicationTemplate.DataAccess; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace ApplicationTemplate.Business; | ||
|
||
/// <summary> | ||
/// Implementation of the IKillSwitchService. | ||
/// </summary> | ||
public class KillSwitchService : IKillSwitchService | ||
public class KillSwitchService : IKillSwitchService, IDisposable | ||
{ | ||
private readonly IKillSwitchRepository _killSwitchRepository; | ||
private readonly ILogger<KillSwitchService> _logger; | ||
private readonly IDisposable _subscription; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="KillSwitchService"/> class. | ||
/// </summary> | ||
/// <param name="killSwitchRepository">The <see cref="IKillSwitchRepository"/>.</param> | ||
public KillSwitchService(IKillSwitchRepository killSwitchRepository) | ||
/// <param name="logger">The <see cref="ILogger{KillSwitchService}"/>.</param> | ||
public KillSwitchService(IKillSwitchRepository killSwitchRepository, ILogger<KillSwitchService> logger) | ||
{ | ||
_killSwitchRepository = killSwitchRepository; | ||
_logger = logger; | ||
|
||
_subscription = _killSwitchRepository.ObserveKillSwitchActivation() | ||
.Subscribe(isActive => | ||
{ | ||
_logger.LogInformation("Kill switch is now {isActive}", isActive); | ||
}); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public IObservable<bool> ObserveKillSwitchActivation() => _killSwitchRepository.ObserveKillSwitchActivation(); | ||
|
||
/// <inheritdoc/> | ||
public void Dispose() | ||
{ | ||
_subscription.Dispose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters