Updated classes to use IOptionsMonitor or IOptionsSnapshot instead of IOptions

This commit is contained in:
Nikolaj Geisle
2021-09-27 09:58:44 +02:00
parent 8ce66277ce
commit e11d6ac280
15 changed files with 57 additions and 45 deletions

View File

@@ -13,13 +13,13 @@ namespace Umbraco.Cms.Web.Website.Controllers
{
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly IIOHelper _ioHelper;
private readonly IOptions<GlobalSettings> _globalSettings;
private readonly GlobalSettings _globalSettings;
public RenderNoContentController(IUmbracoContextAccessor umbracoContextAccessor, IIOHelper ioHelper, IOptions<GlobalSettings> globalSettings)
public RenderNoContentController(IUmbracoContextAccessor umbracoContextAccessor, IIOHelper ioHelper, IOptionsSnapshot<GlobalSettings> globalSettings)
{
_umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
_globalSettings = globalSettings ?? throw new ArgumentNullException(nameof(globalSettings));
_globalSettings = globalSettings.Value ?? throw new ArgumentNullException(nameof(globalSettings));
}
public ActionResult Index()
@@ -34,10 +34,10 @@ namespace Umbraco.Cms.Web.Website.Controllers
var model = new NoNodesViewModel
{
UmbracoPath = _ioHelper.ResolveUrl(_globalSettings.Value.UmbracoPath),
UmbracoPath = _ioHelper.ResolveUrl(_globalSettings.UmbracoPath),
};
return View(_globalSettings.Value.NoNodesViewPath, model);
return View(_globalSettings.NoNodesViewPath, model);
}
}
}