diff --git a/src/Umbraco.Core/HealthChecks/NotificationMethods/EmailNotificationMethod.cs b/src/Umbraco.Core/HealthChecks/NotificationMethods/EmailNotificationMethod.cs index 6abb9b46e8..de6df973e3 100644 --- a/src/Umbraco.Core/HealthChecks/NotificationMethods/EmailNotificationMethod.cs +++ b/src/Umbraco.Core/HealthChecks/NotificationMethods/EmailNotificationMethod.cs @@ -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, - IOptionsSnapshot contentSettings, + IOptionsMonitor healthChecksSettings, + IOptionsMonitor 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; } diff --git a/src/Umbraco.Core/HealthChecks/NotificationMethods/NotificationMethodBase.cs b/src/Umbraco.Core/HealthChecks/NotificationMethods/NotificationMethodBase.cs index 58ff1202ae..3a889154d2 100644 --- a/src/Umbraco.Core/HealthChecks/NotificationMethods/NotificationMethodBase.cs +++ b/src/Umbraco.Core/HealthChecks/NotificationMethods/NotificationMethodBase.cs @@ -8,7 +8,7 @@ namespace Umbraco.Cms.Core.HealthChecks.NotificationMethods { public abstract class NotificationMethodBase : IHealthCheckNotificationMethod { - protected NotificationMethodBase(IOptionsSnapshot healthCheckSettings) + protected NotificationMethodBase(IOptionsMonitor healthCheckSettings) { var type = GetType(); var attribute = type.GetCustomAttribute(); @@ -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; diff --git a/src/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTask.cs b/src/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTask.cs index a37216fbbd..f68f187233 100644 --- a/src/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTask.cs +++ b/src/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTask.cs @@ -22,7 +22,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices.ServerRegistration private readonly IServerRegistrationService _serverRegistrationService; private readonly IHostingEnvironment _hostingEnvironment; private readonly ILogger _logger; - private readonly GlobalSettings _globalSettings; + private GlobalSettings _globalSettings; /// /// Initializes a new instance of the class. @@ -37,14 +37,15 @@ namespace Umbraco.Cms.Infrastructure.HostedServices.ServerRegistration IServerRegistrationService serverRegistrationService, IHostingEnvironment hostingEnvironment, ILogger logger, - IOptionsSnapshot globalSettings) - : base(globalSettings.Value.DatabaseServerRegistrar.WaitTimeBetweenCalls, TimeSpan.FromSeconds(15)) + IOptionsMonitor globalSettings) + : base(globalSettings.CurrentValue.DatabaseServerRegistrar.WaitTimeBetweenCalls, TimeSpan.FromSeconds(15)) { _runtimeState = runtimeState; _serverRegistrationService = serverRegistrationService ?? throw new ArgumentNullException(nameof(serverRegistrationService)); _hostingEnvironment = hostingEnvironment; _logger = logger; - _globalSettings = globalSettings.Value; + _globalSettings = globalSettings.CurrentValue; + globalSettings.OnChange(x => _globalSettings = x); } public override Task PerformExecuteAsync(object state) diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTaskTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTaskTests.cs index da8ef3d5fa..793acdfa3e 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTaskTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTaskTests.cs @@ -77,7 +77,7 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.HostedServices.Serv _mockServerRegistrationService.Object, mockRequestAccessor.Object, mockLogger.Object, - new TestOptionsSnapshot(settings)); + new TestOptionsMonitor(settings)); } private void VerifyServerNotTouched() => VerifyServerTouchedTimes(Times.Never());