Changed some classes back to use IOptionsMonitor as they are singleton services

Signed-off-by: Nikolaj Geisle <niko737@edu.ucl.dk>
This commit is contained in:
Nikolaj Geisle
2021-10-04 10:28:59 +02:00
parent 4d35600288
commit 20b95de2d1
4 changed files with 14 additions and 12 deletions

View File

@@ -17,15 +17,14 @@ namespace Umbraco.Cms.Core.HealthChecks.NotificationMethods
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IEmailSender _emailSender;
private readonly IMarkdownToHtmlConverter _markdownToHtmlConverter;
private readonly ContentSettings _contentSettings;
private ContentSettings _contentSettings;
public EmailNotificationMethod(
ILocalizedTextService textService,
IHostingEnvironment hostingEnvironment,
IEmailSender emailSender,
IOptionsSnapshot<HealthChecksSettings> healthChecksSettings,
IOptionsSnapshot<ContentSettings> contentSettings,
IOptionsMonitor<HealthChecksSettings> healthChecksSettings,
IOptionsMonitor<ContentSettings> contentSettings,
IMarkdownToHtmlConverter markdownToHtmlConverter)
: base(healthChecksSettings)
{
@@ -42,7 +41,9 @@ namespace Umbraco.Cms.Core.HealthChecks.NotificationMethods
_hostingEnvironment = hostingEnvironment;
_emailSender = emailSender;
_markdownToHtmlConverter = markdownToHtmlConverter;
_contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings));
_contentSettings = contentSettings.CurrentValue ?? throw new ArgumentNullException(nameof(contentSettings));
contentSettings.OnChange(x => _contentSettings = x);
}
public string RecipientEmail { get; }

View File

@@ -8,7 +8,7 @@ namespace Umbraco.Cms.Core.HealthChecks.NotificationMethods
{
public abstract class NotificationMethodBase : IHealthCheckNotificationMethod
{
protected NotificationMethodBase(IOptionsSnapshot<HealthChecksSettings> healthCheckSettings)
protected NotificationMethodBase(IOptionsMonitor<HealthChecksSettings> healthCheckSettings)
{
var type = GetType();
var attribute = type.GetCustomAttribute<HealthCheckNotificationMethodAttribute>();
@@ -18,7 +18,7 @@ namespace Umbraco.Cms.Core.HealthChecks.NotificationMethods
return;
}
var notificationMethods = healthCheckSettings.Value.Notification.NotificationMethods;
var notificationMethods = healthCheckSettings.CurrentValue.Notification.NotificationMethods;
if (!notificationMethods.TryGetValue(attribute.Alias, out var notificationMethod))
{
Enabled = false;