From 64f875258793ec941b6f0b2a56df40e184a459b9 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Wed, 26 Aug 2020 11:58:44 +0200 Subject: [PATCH] Removed introduced second constructors for IOptions based depenedencies and used Options.Create instead. --- src/Umbraco.Core/Routing/PublishedRequest.cs | 13 +--------- src/Umbraco.Core/Routing/PublishedRouter.cs | 2 +- src/Umbraco.Core/Scheduling/KeepAlive.cs | 8 +----- .../BackOffice/BackOfficeUserStore.cs | 7 +---- .../EmailNotificationMethod.cs | 2 +- .../Media/UploadAutoFillProperties.cs | 10 +------ .../Repositories/Implement/UserRepository.cs | 26 ++----------------- .../FileUploadPropertyEditor.cs | 18 +++---------- .../FileUploadPropertyValueEditor.cs | 14 +--------- .../ImageCropperPropertyEditor.cs | 20 ++------------ .../UploadFileTypeValidator.cs | 9 ++----- .../Scheduling/LogScrubber.cs | 8 +----- .../Scheduling/SchedulerComponent.cs | 4 +-- .../Scoping/ScopeProvider.cs | 7 +---- .../Services/Implement/NotificationService.cs | 10 ++----- .../Users/EmailSender.cs | 11 +------- .../ContentCache.cs | 7 +---- .../PublishedSnapshotService.cs | 2 +- .../Repositories/UserRepositoryTest.cs | 4 +-- .../Components/ComponentTests.cs | 2 +- src/Umbraco.Tests/Models/MediaXmlTest.cs | 2 +- .../Repositories/UserRepositoryTest.cs | 2 +- .../Security/BackOfficeOwinUserManager.cs | 2 +- 23 files changed, 31 insertions(+), 159 deletions(-) diff --git a/src/Umbraco.Core/Routing/PublishedRequest.cs b/src/Umbraco.Core/Routing/PublishedRequest.cs index d1bf6fda0f..3e13270fa0 100644 --- a/src/Umbraco.Core/Routing/PublishedRequest.cs +++ b/src/Umbraco.Core/Routing/PublishedRequest.cs @@ -36,21 +36,10 @@ namespace Umbraco.Web.Routing /// The Umbraco context. /// The request Uri. public PublishedRequest(IPublishedRouter publishedRouter, IUmbracoContext umbracoContext, IOptions webRoutingSettings, Uri uri = null) - : this(publishedRouter, umbracoContext, webRoutingSettings.Value, uri) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The published router. - /// The Umbraco context. - /// The request Uri. - public PublishedRequest(IPublishedRouter publishedRouter, IUmbracoContext umbracoContext, WebRoutingSettings webRoutingSettings, Uri uri = null) { UmbracoContext = umbracoContext ?? throw new ArgumentNullException(nameof(umbracoContext)); _publishedRouter = publishedRouter ?? throw new ArgumentNullException(nameof(publishedRouter)); - _webRoutingSettings = webRoutingSettings; + _webRoutingSettings = webRoutingSettings.Value; Uri = uri ?? umbracoContext.CleanedUmbracoUrl; } diff --git a/src/Umbraco.Core/Routing/PublishedRouter.cs b/src/Umbraco.Core/Routing/PublishedRouter.cs index 207e8d7ed4..6de64800c3 100644 --- a/src/Umbraco.Core/Routing/PublishedRouter.cs +++ b/src/Umbraco.Core/Routing/PublishedRouter.cs @@ -69,7 +69,7 @@ namespace Umbraco.Web.Routing /// public IPublishedRequest CreateRequest(IUmbracoContext umbracoContext, Uri uri = null) { - return new PublishedRequest(this, umbracoContext, _webRoutingSettings, uri ?? umbracoContext.CleanedUmbracoUrl); + return new PublishedRequest(this, umbracoContext, Options.Create(_webRoutingSettings), uri ?? umbracoContext.CleanedUmbracoUrl); } #region Request diff --git a/src/Umbraco.Core/Scheduling/KeepAlive.cs b/src/Umbraco.Core/Scheduling/KeepAlive.cs index dec9d9daad..98c6268e69 100644 --- a/src/Umbraco.Core/Scheduling/KeepAlive.cs +++ b/src/Umbraco.Core/Scheduling/KeepAlive.cs @@ -21,17 +21,11 @@ namespace Umbraco.Web.Scheduling public KeepAlive(IBackgroundTaskRunner runner, int delayMilliseconds, int periodMilliseconds, IRequestAccessor requestAccessor, IMainDom mainDom, IOptions keepAliveSettings, IProfilingLogger logger, IServerRegistrar serverRegistrar) - : this(runner, delayMilliseconds, periodMilliseconds, requestAccessor, mainDom, keepAliveSettings.Value, logger, serverRegistrar) - { - } - - public KeepAlive(IBackgroundTaskRunner runner, int delayMilliseconds, int periodMilliseconds, - IRequestAccessor requestAccessor, IMainDom mainDom, KeepAliveSettings keepAliveSettings, IProfilingLogger logger, IServerRegistrar serverRegistrar) : base(runner, delayMilliseconds, periodMilliseconds) { _requestAccessor = requestAccessor; _mainDom = mainDom; - _keepAliveSettings = keepAliveSettings; + _keepAliveSettings = keepAliveSettings.Value; _logger = logger; _serverRegistrar = serverRegistrar; if (_httpClient == null) diff --git a/src/Umbraco.Infrastructure/BackOffice/BackOfficeUserStore.cs b/src/Umbraco.Infrastructure/BackOffice/BackOfficeUserStore.cs index 0c5f5fd6ab..d14a951877 100644 --- a/src/Umbraco.Infrastructure/BackOffice/BackOfficeUserStore.cs +++ b/src/Umbraco.Infrastructure/BackOffice/BackOfficeUserStore.cs @@ -39,16 +39,11 @@ namespace Umbraco.Core.BackOffice private bool _disposed = false; public BackOfficeUserStore(IUserService userService, IEntityService entityService, IExternalLoginService externalLoginService, IOptions globalSettings, UmbracoMapper mapper) - : this(userService, entityService, externalLoginService, globalSettings.Value, mapper) - { - } - - public BackOfficeUserStore(IUserService userService, IEntityService entityService, IExternalLoginService externalLoginService, GlobalSettings globalSettings, UmbracoMapper mapper) { _userService = userService; _entityService = entityService; _externalLoginService = externalLoginService; - _globalSettings = globalSettings; + _globalSettings = globalSettings.Value; if (userService == null) throw new ArgumentNullException("userService"); if (externalLoginService == null) throw new ArgumentNullException("externalLoginService"); _mapper = mapper; diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs index 19d63d7d6a..49981b0b9a 100644 --- a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs +++ b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs @@ -70,7 +70,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods var subject = _textService.Localize("healthcheck/scheduledHealthCheckEmailSubject", new[] { host.ToString() }); - var mailSender = new EmailSender(_globalSettings); + var mailSender = new EmailSender(Options.Create(_globalSettings)); using (var mailMessage = CreateMailMessage(subject, message)) { await mailSender.SendAsync(mailMessage); diff --git a/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs b/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs index 3f8c1c217f..762e418441 100644 --- a/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs +++ b/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs @@ -25,18 +25,10 @@ namespace Umbraco.Web.Media IMediaFileSystem mediaFileSystem, ILogger logger, IOptions contentSettings) - : this(mediaFileSystem, logger, contentSettings.Value) - { - } - - public UploadAutoFillProperties( - IMediaFileSystem mediaFileSystem, - ILogger logger, - ContentSettings contentSettings) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - _contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings)); + _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings)); } /// diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs index 83bc3730b8..72c7ea8b33 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs @@ -50,33 +50,11 @@ namespace Umbraco.Core.Persistence.Repositories.Implement IOptions globalSettings, IOptions passwordConfiguration, IJsonSerializer jsonSerializer) - : this(scopeAccessor, appCaches, logger, mapperCollection, globalSettings.Value, passwordConfiguration.Value, jsonSerializer) - { - } - - /// - /// Constructor - /// - /// - /// - /// - /// - /// A dictionary specifying the configuration for user passwords. If this is null then no password configuration will be persisted or read. - /// - /// - public UserRepository( - IScopeAccessor scopeAccessor, - AppCaches appCaches, - ILogger logger, - IMapperCollection mapperCollection, - GlobalSettings globalSettings, - UserPasswordConfigurationSettings passwordConfiguration, - IJsonSerializer jsonSerializer) : base(scopeAccessor, appCaches, logger) { _mapperCollection = mapperCollection ?? throw new ArgumentNullException(nameof(mapperCollection)); - _globalSettings = globalSettings ?? throw new ArgumentNullException(nameof(globalSettings)); - _passwordConfiguration = passwordConfiguration ?? throw new ArgumentNullException(nameof(passwordConfiguration)); + _globalSettings = globalSettings.Value ?? throw new ArgumentNullException(nameof(globalSettings)); + _passwordConfiguration = passwordConfiguration.Value ?? throw new ArgumentNullException(nameof(passwordConfiguration)); _jsonSerializer = jsonSerializer; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs index 1297a0ba2d..d4c5130b21 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs @@ -38,22 +38,10 @@ namespace Umbraco.Web.PropertyEditors ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : this(logger, mediaFileSystem, contentSettings.Value, dataTypeService, localizationService, localizedTextService, shortStringHelper) - { - } - - public FileUploadPropertyEditor( - ILogger logger, - IMediaFileSystem mediaFileSystem, - ContentSettings contentSettings, - IDataTypeService dataTypeService, - ILocalizationService localizationService, - ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) : base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); - _contentSettings = contentSettings; + _contentSettings = contentSettings.Value; _dataTypeService = dataTypeService; _localizationService = localizationService; _localizedTextService = localizedTextService; @@ -66,8 +54,8 @@ namespace Umbraco.Web.PropertyEditors /// The corresponding property value editor. protected override IDataValueEditor CreateValueEditor() { - var editor = new FileUploadPropertyValueEditor(Attribute, _mediaFileSystem, _dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, _contentSettings); - editor.Validators.Add(new UploadFileTypeValidator(_localizedTextService, _contentSettings)); + var editor = new FileUploadPropertyValueEditor(Attribute, _mediaFileSystem, _dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, Options.Create(_contentSettings)); + editor.Validators.Add(new UploadFileTypeValidator(_localizedTextService, Options.Create(_contentSettings))); return editor; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs index 7425051480..db675e2e42 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs @@ -27,22 +27,10 @@ namespace Umbraco.Web.PropertyEditors ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IOptions contentSettings) - : this(attribute, mediaFileSystem, dataTypeService, localizationService, localizedTextService, shortStringHelper, contentSettings.Value) - { - } - - public FileUploadPropertyValueEditor( - DataEditorAttribute attribute, - IMediaFileSystem mediaFileSystem, - IDataTypeService dataTypeService, - ILocalizationService localizationService, - ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper, - ContentSettings contentSettings) : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); - _contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings)); + _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings)); } /// diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs index 2b1efb6d2b..0fea46f2d3 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs @@ -49,32 +49,16 @@ namespace Umbraco.Web.PropertyEditors IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService) - : this(logger, mediaFileSystem, contentSettings.Value, dataTypeService, localizationService, ioHelper, shortStringHelper, localizedTextService) - { - } - - /// - /// Initializes a new instance of the class. - /// - public ImageCropperPropertyEditor( - ILogger logger, - IMediaFileSystem mediaFileSystem, - ContentSettings contentSettings, - IDataTypeService dataTypeService, - ILocalizationService localizationService, - IIOHelper ioHelper, - IShortStringHelper shortStringHelper, - ILocalizedTextService localizedTextService) : base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); - _contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings)); + _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings)); _dataTypeService = dataTypeService; _localizationService = localizationService; _ioHelper = ioHelper; // TODO: inject? - _autoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, _contentSettings); + _autoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, contentSettings); } public bool TryGetMediaPath(string alias, object value, out string mediaPath) diff --git a/src/Umbraco.Infrastructure/PropertyEditors/UploadFileTypeValidator.cs b/src/Umbraco.Infrastructure/PropertyEditors/UploadFileTypeValidator.cs index 72391c99c0..d3e1e7aabe 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/UploadFileTypeValidator.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/UploadFileTypeValidator.cs @@ -17,15 +17,10 @@ namespace Umbraco.Web.PropertyEditors private readonly ILocalizedTextService _localizedTextService; private readonly ContentSettings _contentSettings; - public UploadFileTypeValidator(ILocalizedTextService localizedTextService, ContentSettings contentSettings) + public UploadFileTypeValidator(ILocalizedTextService localizedTextService, IOptions contentSettings) { _localizedTextService = localizedTextService; - _contentSettings = contentSettings; - } - - public UploadFileTypeValidator(ILocalizedTextService localizedTextService, IOptions contentSettings) - : this(localizedTextService, contentSettings.Value) - { + _contentSettings = contentSettings.Value; } public IEnumerable Validate(object value, string valueType, object dataTypeConfiguration) diff --git a/src/Umbraco.Infrastructure/Scheduling/LogScrubber.cs b/src/Umbraco.Infrastructure/Scheduling/LogScrubber.cs index 2aff2ce5ab..51c62de581 100644 --- a/src/Umbraco.Infrastructure/Scheduling/LogScrubber.cs +++ b/src/Umbraco.Infrastructure/Scheduling/LogScrubber.cs @@ -21,18 +21,12 @@ namespace Umbraco.Web.Scheduling public LogScrubber(IBackgroundTaskRunner runner, int delayMilliseconds, int periodMilliseconds, IMainDom mainDom, IServerRegistrar serverRegistrar, IAuditService auditService, IOptions settings, IScopeProvider scopeProvider, IProfilingLogger logger) - : this(runner, delayMilliseconds, periodMilliseconds, mainDom, serverRegistrar, auditService, settings.Value, scopeProvider, logger) - { - } - - public LogScrubber(IBackgroundTaskRunner runner, int delayMilliseconds, int periodMilliseconds, - IMainDom mainDom, IServerRegistrar serverRegistrar, IAuditService auditService, LoggingSettings settings, IScopeProvider scopeProvider, IProfilingLogger logger) : base(runner, delayMilliseconds, periodMilliseconds) { _mainDom = mainDom; _serverRegistrar = serverRegistrar; _auditService = auditService; - _settings = settings; + _settings = settings.Value; _scopeProvider = scopeProvider; _logger = logger; } diff --git a/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs b/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs index cfa9ced735..8aabaf0b57 100644 --- a/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs +++ b/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs @@ -141,7 +141,7 @@ namespace Umbraco.Web.Scheduling { // ping/keepalive // on all servers - var task = new KeepAlive(_keepAliveRunner, DefaultDelayMilliseconds, FiveMinuteMilliseconds, _requestAccessor, _mainDom, keepAliveSettings, _logger, _serverRegistrar); + var task = new KeepAlive(_keepAliveRunner, DefaultDelayMilliseconds, FiveMinuteMilliseconds, _requestAccessor, _mainDom, Options.Create(keepAliveSettings), _logger, _serverRegistrar); _keepAliveRunner.TryAdd(task); return task; } @@ -185,7 +185,7 @@ namespace Umbraco.Web.Scheduling { // log scrubbing // install on all, will only run on non-replica servers - var task = new LogScrubber(_scrubberRunner, DefaultDelayMilliseconds, LogScrubber.GetLogScrubbingInterval(), _mainDom, _serverRegistrar, _auditService, settings, _scopeProvider, _logger); + var task = new LogScrubber(_scrubberRunner, DefaultDelayMilliseconds, LogScrubber.GetLogScrubbingInterval(), _mainDom, _serverRegistrar, _auditService, Options.Create(settings), _scopeProvider, _logger); _scrubberRunner.TryAdd(task); return task; } diff --git a/src/Umbraco.Infrastructure/Scoping/ScopeProvider.cs b/src/Umbraco.Infrastructure/Scoping/ScopeProvider.cs index 947d427995..a2f626909b 100644 --- a/src/Umbraco.Infrastructure/Scoping/ScopeProvider.cs +++ b/src/Umbraco.Infrastructure/Scoping/ScopeProvider.cs @@ -29,15 +29,10 @@ namespace Umbraco.Core.Scoping private readonly IMediaFileSystem _mediaFileSystem; public ScopeProvider(IUmbracoDatabaseFactory databaseFactory, FileSystems fileSystems, IOptions coreDebugSettings, IMediaFileSystem mediaFileSystem, ILogger logger, ITypeFinder typeFinder, IRequestCache requestCache) - :this(databaseFactory, fileSystems, coreDebugSettings.Value, mediaFileSystem, logger, typeFinder, requestCache) - { - } - - public ScopeProvider(IUmbracoDatabaseFactory databaseFactory, FileSystems fileSystems, CoreDebugSettings coreDebugSettings, IMediaFileSystem mediaFileSystem, ILogger logger, ITypeFinder typeFinder, IRequestCache requestCache) { DatabaseFactory = databaseFactory; _fileSystems = fileSystems; - _coreDebugSettings = coreDebugSettings; + _coreDebugSettings = coreDebugSettings.Value; _mediaFileSystem = mediaFileSystem; _logger = logger; _typeFinder = typeFinder; diff --git a/src/Umbraco.Infrastructure/Services/Implement/NotificationService.cs b/src/Umbraco.Infrastructure/Services/Implement/NotificationService.cs index 9b0045da7b..6058427aae 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/NotificationService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/NotificationService.cs @@ -33,16 +33,10 @@ namespace Umbraco.Core.Services.Implement public NotificationService(IScopeProvider provider, IUserService userService, IContentService contentService, ILocalizationService localizationService, ILogger logger, IIOHelper ioHelper, INotificationsRepository notificationsRepository, IOptions globalSettings, IOptions contentSettings, IEmailSender emailSender) - : this(provider, userService, contentService, localizationService, logger, ioHelper, notificationsRepository, globalSettings.Value, contentSettings.Value, emailSender) - { - } - - public NotificationService(IScopeProvider provider, IUserService userService, IContentService contentService, ILocalizationService localizationService, - ILogger logger, IIOHelper ioHelper, INotificationsRepository notificationsRepository, GlobalSettings globalSettings, ContentSettings contentSettings, IEmailSender emailSender) { _notificationsRepository = notificationsRepository; - _globalSettings = globalSettings; - _contentSettings = contentSettings; + _globalSettings = globalSettings.Value; + _contentSettings = contentSettings.Value; _emailSender = emailSender; _uowProvider = provider ?? throw new ArgumentNullException(nameof(provider)); _userService = userService ?? throw new ArgumentNullException(nameof(userService)); diff --git a/src/Umbraco.Infrastructure/Users/EmailSender.cs b/src/Umbraco.Infrastructure/Users/EmailSender.cs index d563a0c36f..c45a9af0d3 100644 --- a/src/Umbraco.Infrastructure/Users/EmailSender.cs +++ b/src/Umbraco.Infrastructure/Users/EmailSender.cs @@ -27,17 +27,8 @@ namespace Umbraco.Core } public EmailSender(IOptions globalSettings, bool enableEvents) - : this(globalSettings.Value, enableEvents) { - } - - public EmailSender(GlobalSettings globalSettings) : this(globalSettings, false) - { - } - - public EmailSender(GlobalSettings globalSettings, bool enableEvents) - { - _globalSettings = globalSettings; + _globalSettings = globalSettings.Value; _enableEvents = enableEvents; _smtpConfigured = new Lazy(() => _globalSettings.IsSmtpServerConfigured); diff --git a/src/Umbraco.PublishedCache.NuCache/ContentCache.cs b/src/Umbraco.PublishedCache.NuCache/ContentCache.cs index f18018d9f0..1bdb3711d1 100644 --- a/src/Umbraco.PublishedCache.NuCache/ContentCache.cs +++ b/src/Umbraco.PublishedCache.NuCache/ContentCache.cs @@ -32,18 +32,13 @@ namespace Umbraco.Web.PublishedCache.NuCache // but, no, UmbracoContext returns snapshot.Content which comes from elements SO a resync should create a new cache public ContentCache(bool previewDefault, ContentStore.Snapshot snapshot, IAppCache snapshotCache, IAppCache elementsCache, IDomainCache domainCache, IOptions globalSettings, IVariationContextAccessor variationContextAccessor) - : this(previewDefault, snapshot, snapshotCache, elementsCache, domainCache, globalSettings.Value, variationContextAccessor) - { - } - - public ContentCache(bool previewDefault, ContentStore.Snapshot snapshot, IAppCache snapshotCache, IAppCache elementsCache, IDomainCache domainCache, GlobalSettings globalSettings, IVariationContextAccessor variationContextAccessor) : base(previewDefault) { _snapshot = snapshot; _snapshotCache = snapshotCache; _elementsCache = elementsCache; _domainCache = domainCache; - _globalSettings = globalSettings; + _globalSettings = globalSettings.Value; _variationContextAccessor = variationContextAccessor; } diff --git a/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs b/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs index fabcb0c759..adadef337f 100644 --- a/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs @@ -1239,7 +1239,7 @@ namespace Umbraco.Web.PublishedCache.NuCache return new PublishedSnapshot.PublishedSnapshotElements { - ContentCache = new ContentCache(previewDefault, contentSnap, snapshotCache, elementsCache, domainCache, _globalSettings, VariationContextAccessor), + ContentCache = new ContentCache(previewDefault, contentSnap, snapshotCache, elementsCache, domainCache, Options.Create(_globalSettings), VariationContextAccessor), MediaCache = new MediaCache(previewDefault, mediaSnap, VariationContextAccessor), MemberCache = new MemberCache(previewDefault, snapshotCache, _serviceContext.MemberService, memberTypeCache, PublishedSnapshotAccessor, VariationContextAccessor, _entitySerializer, _publishedModelFactory), DomainCache = domainCache, diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/UserRepositoryTest.cs b/src/Umbraco.Tests.Integration/Persistence/Repositories/UserRepositoryTest.cs index cf8f091dbc..df5e58e82a 100644 --- a/src/Umbraco.Tests.Integration/Persistence/Repositories/UserRepositoryTest.cs +++ b/src/Umbraco.Tests.Integration/Persistence/Repositories/UserRepositoryTest.cs @@ -27,7 +27,7 @@ namespace Umbraco.Tests.Persistence.Repositories private UserRepository CreateRepository(IScopeProvider provider) { var accessor = (IScopeAccessor) provider; - var repository = new UserRepository(accessor, AppCaches.Disabled, Logger, Mappers, GlobalSettings, new UserPasswordConfigurationSettings(), new JsonNetSerializer()); + var repository = new UserRepository(accessor, AppCaches.Disabled, Logger, Mappers, Options.Create(GlobalSettings), Options.Create(new UserPasswordConfigurationSettings()), new JsonNetSerializer()); return repository; } @@ -119,7 +119,7 @@ namespace Umbraco.Tests.Persistence.Repositories var id = user.Id; - var repository2 = new UserRepository((IScopeAccessor) provider, AppCaches.Disabled, Logger, Mock.Of(), GlobalSettings, new UserPasswordConfigurationSettings(), new JsonNetSerializer()); + var repository2 = new UserRepository((IScopeAccessor) provider, AppCaches.Disabled, Logger, Mock.Of(), Options.Create(GlobalSettings), Options.Create(new UserPasswordConfigurationSettings()), new JsonNetSerializer()); repository2.Delete(user); diff --git a/src/Umbraco.Tests/Components/ComponentTests.cs b/src/Umbraco.Tests/Components/ComponentTests.cs index 4ce790db6c..aef126729c 100644 --- a/src/Umbraco.Tests/Components/ComponentTests.cs +++ b/src/Umbraco.Tests/Components/ComponentTests.cs @@ -41,7 +41,7 @@ namespace Umbraco.Tests.Components var fs = new FileSystems(mock.Object, logger, TestHelper.IOHelper, Options.Create(globalSettings), TestHelper.GetHostingEnvironment()); var coreDebug = new CoreDebugSettingsBuilder().Build(); var mediaFileSystem = Mock.Of(); - var p = new ScopeProvider(f, fs, coreDebug, mediaFileSystem, logger, typeFinder, NoAppCache.Instance); + var p = new ScopeProvider(f, fs, Microsoft.Extensions.Options.Options.Create(coreDebug), mediaFileSystem, logger, typeFinder, NoAppCache.Instance); mock.Setup(x => x.GetInstance(typeof (ILogger))).Returns(logger); mock.Setup(x => x.GetInstance(typeof (IProfilingLogger))).Returns(new ProfilingLogger(Mock.Of(), Mock.Of())); diff --git a/src/Umbraco.Tests/Models/MediaXmlTest.cs b/src/Umbraco.Tests/Models/MediaXmlTest.cs index b40e56c252..593a581f85 100644 --- a/src/Umbraco.Tests/Models/MediaXmlTest.cs +++ b/src/Umbraco.Tests/Models/MediaXmlTest.cs @@ -35,7 +35,7 @@ namespace Umbraco.Tests.Models var contentSettings = new ContentSettingsBuilder().Build(); var mediaFileSystem = new MediaFileSystem(Mock.Of(), scheme, logger, ShortStringHelper); - var ignored = new FileUploadPropertyEditor(Mock.Of(), mediaFileSystem, contentSettings, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper); + var ignored = new FileUploadPropertyEditor(Mock.Of(), mediaFileSystem, Microsoft.Extensions.Options.Options.Create(contentSettings), DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper); var media = MockedMedia.CreateMediaImage(mediaType, -1); media.WriterId = -1; // else it's zero and that's not a user and it breaks the tests diff --git a/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs index e49d6854d2..ddb8794e90 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs @@ -73,7 +73,7 @@ namespace Umbraco.Tests.Persistence.Repositories { var accessor = (IScopeAccessor) provider; var globalSettings = new GlobalSettingsBuilder().Build(); - var repository = new UserRepository(accessor, AppCaches.Disabled, Logger, Mappers, globalSettings, new UserPasswordConfigurationSettings(), new JsonNetSerializer()); + var repository = new UserRepository(accessor, AppCaches.Disabled, Logger, Mappers, Microsoft.Extensions.Options.Options.Create(globalSettings), Microsoft.Extensions.Options.Options.Create(new UserPasswordConfigurationSettings()), new JsonNetSerializer()); return repository; } diff --git a/src/Umbraco.Web/Security/BackOfficeOwinUserManager.cs b/src/Umbraco.Web/Security/BackOfficeOwinUserManager.cs index 13dd242d26..51b5947a99 100644 --- a/src/Umbraco.Web/Security/BackOfficeOwinUserManager.cs +++ b/src/Umbraco.Web/Security/BackOfficeOwinUserManager.cs @@ -54,7 +54,7 @@ namespace Umbraco.Web.Security IDataProtectionProvider dataProtectionProvider, ILogger> logger) { - var store = new BackOfficeUserStore(userService, entityService, externalLoginService, ConfigModelConversionsFromLegacy.ConvertGlobalSettings(globalSettings), mapper); + var store = new BackOfficeUserStore(userService, entityService, externalLoginService, Microsoft.Extensions.Options.Options.Create(ConfigModelConversionsFromLegacy.ConvertGlobalSettings(globalSettings)), mapper); return Create( passwordConfiguration,