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,7 +24,7 @@ namespace Umbraco.Cms.Core.Routing
/// </summary>
public class PublishedRouter : IPublishedRouter
{
private readonly WebRoutingSettings _webRoutingSettings;
private WebRoutingSettings _webRoutingSettings;
private readonly ContentFinderCollection _contentFinders;
private readonly IContentLastChanceFinder _contentLastChanceFinder;
private readonly IProfilingLogger _profilingLogger;
@@ -42,7 +42,7 @@ namespace Umbraco.Cms.Core.Routing
/// Initializes a new instance of the <see cref="PublishedRouter"/> class.
/// </summary>
public PublishedRouter(
IOptions<WebRoutingSettings> webRoutingSettings,
IOptionsMonitor<WebRoutingSettings> webRoutingSettings,
ContentFinderCollection contentFinders,
IContentLastChanceFinder contentLastChanceFinder,
IVariationContextAccessor variationContextAccessor,
@@ -56,7 +56,7 @@ namespace Umbraco.Cms.Core.Routing
IUmbracoContextAccessor umbracoContextAccessor,
IEventAggregator eventAggregator)
{
_webRoutingSettings = webRoutingSettings.Value ?? throw new ArgumentNullException(nameof(webRoutingSettings));
_webRoutingSettings = webRoutingSettings.CurrentValue ?? throw new ArgumentNullException(nameof(webRoutingSettings));
_contentFinders = contentFinders ?? throw new ArgumentNullException(nameof(contentFinders));
_contentLastChanceFinder = contentLastChanceFinder ?? throw new ArgumentNullException(nameof(contentLastChanceFinder));
_profilingLogger = proflog ?? throw new ArgumentNullException(nameof(proflog));
@@ -69,6 +69,7 @@ namespace Umbraco.Cms.Core.Routing
_contentTypeService = contentTypeService;
_umbracoContextAccessor = umbracoContextAccessor;
_eventAggregator = eventAggregator;
webRoutingSettings.OnChange(x => _webRoutingSettings = x);
}
/// <inheritdoc />
@@ -237,7 +238,7 @@ namespace Umbraco.Cms.Core.Routing
// re-route
await RouteRequestInternalAsync(builder);
// return if we are redirect
if (builder.IsRedirect())
{