Updated Classes to use IOptionsMonitor or IOptionsSnapshot instead of IOptions

This commit is contained in:
Nikolaj Geisle
2021-09-23 12:54:12 +02:00
parent eb01984763
commit 10c2561d0a
16 changed files with 51 additions and 37 deletions

View File

@@ -24,8 +24,8 @@ namespace Umbraco.Cms.Core.HealthChecks.NotificationMethods
ILocalizedTextService textService,
IHostingEnvironment hostingEnvironment,
IEmailSender emailSender,
IOptions<HealthChecksSettings> healthChecksSettings,
IOptions<ContentSettings> contentSettings,
IOptionsMonitor<HealthChecksSettings> healthChecksSettings,
IOptionsMonitor<ContentSettings> contentSettings,
IMarkdownToHtmlConverter markdownToHtmlConverter)
: base(healthChecksSettings)
{
@@ -42,7 +42,7 @@ 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));
}
public string RecipientEmail { get; }

View File

@@ -8,7 +8,7 @@ namespace Umbraco.Cms.Core.HealthChecks.NotificationMethods
{
public abstract class NotificationMethodBase : IHealthCheckNotificationMethod
{
protected NotificationMethodBase(IOptions<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;