diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs index 4db386e3a4..b7957d17c1 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs @@ -47,8 +47,8 @@ namespace Umbraco.Tests.PublishedContent typeof(YesNoPropertyEditorValueConverter) }); - PublishedContentCacheResolver.Current = new PublishedContentCacheResolver(new PublishedContentCache()); - PublishedMediaCacheResolver.Current = new PublishedMediaCacheResolver(new PublishedMediaCache()); + PublishedCachesResolver.Current = new PublishedCachesResolver(new PublishedCaches( + new PublishedContentCache(), new PublishedMediaCache())); base.FreezeResolution(); } diff --git a/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs b/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs index 654d32bab3..6fac44e2cb 100644 --- a/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs @@ -215,7 +215,7 @@ namespace Umbraco.Web.Cache // are creating a nasty dependency - but keep it like that for the time being while // SD is cleaning cache refreshers up. - var contentCache = PublishedContentCacheResolver.Current.ContentCache as PublishedContentCache; + var contentCache = PublishedCachesResolver.Current.Caches.ContentCache as PublishedContentCache; if (contentCache != null) contentCache.RoutesCache.Clear(); } diff --git a/src/Umbraco.Web/Cache/DomainCacheRefresher.cs b/src/Umbraco.Web/Cache/DomainCacheRefresher.cs index c08d2f37a7..27a8a70eda 100644 --- a/src/Umbraco.Web/Cache/DomainCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/DomainCacheRefresher.cs @@ -48,7 +48,7 @@ namespace Umbraco.Web.Cache // are creating a nasty dependency - but keep it like that for the time being while // SD is cleaning cache refreshers up. - var contentCache = PublishedContentCacheResolver.Current.ContentCache as PublishedContentCache; + var contentCache = PublishedCachesResolver.Current.Caches.ContentCache as PublishedContentCache; if (contentCache != null) contentCache.RoutesCache.Clear(); } diff --git a/src/Umbraco.Web/PublishedCache/IPublishedCaches.cs b/src/Umbraco.Web/PublishedCache/IPublishedCaches.cs new file mode 100644 index 0000000000..21652d9ed2 --- /dev/null +++ b/src/Umbraco.Web/PublishedCache/IPublishedCaches.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Umbraco.Web.PublishedCache +{ + /// + /// Provides caches (content and media). + /// + /// Groups caches that _may_ be related. + interface IPublishedCaches + { + /// + /// Gets the content cache. + /// + IPublishedContentCache ContentCache { get; } + + /// + /// Gets the media cache. + /// + IPublishedMediaCache MediaCache { get; } + } +} diff --git a/src/Umbraco.Web/PublishedCache/PublishedCaches.cs b/src/Umbraco.Web/PublishedCache/PublishedCaches.cs new file mode 100644 index 0000000000..146677418b --- /dev/null +++ b/src/Umbraco.Web/PublishedCache/PublishedCaches.cs @@ -0,0 +1,29 @@ +namespace Umbraco.Web.PublishedCache +{ + /// + /// Provides caches (content and media). + /// + /// Default implementation for unrelated caches. + class PublishedCaches : IPublishedCaches + { + /// + /// Initializes a new instance of the class with a content cache + /// and a media cache. + /// + public PublishedCaches(IPublishedContentCache contentCache, IPublishedMediaCache mediaCache) + { + ContentCache = contentCache; + MediaCache = mediaCache; + } + + /// + /// Gets the content cache. + /// + public IPublishedContentCache ContentCache { get; private set; } + + /// + /// Gets the media cache. + /// + public IPublishedMediaCache MediaCache { get; private set; } + } +} diff --git a/src/Umbraco.Web/PublishedCache/PublishedCachesResolver.cs b/src/Umbraco.Web/PublishedCache/PublishedCachesResolver.cs new file mode 100644 index 0000000000..129b876a4f --- /dev/null +++ b/src/Umbraco.Web/PublishedCache/PublishedCachesResolver.cs @@ -0,0 +1,37 @@ +using Umbraco.Core.ObjectResolution; + +namespace Umbraco.Web.PublishedCache +{ + /// + /// Resolves the IPublishedCaches object. + /// + internal sealed class PublishedCachesResolver : SingleObjectResolverBase + { + /// + /// Initializes a new instance of the class with caches. + /// + /// The caches. + /// The resolver is created by the WebBootManager and thus the constructor remains internal. + internal PublishedCachesResolver(IPublishedCaches caches) + : base(caches) + { } + + /// + /// Sets the caches. + /// + /// The caches. + /// For developers, at application startup. + public void SetCache(IPublishedCaches caches) + { + Value = caches; + } + + /// + /// Gets the caches. + /// + public IPublishedCaches Caches + { + get { return Value; } + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/PublishedCache/PublishedContentCacheResolver.cs b/src/Umbraco.Web/PublishedCache/PublishedContentCacheResolver.cs deleted file mode 100644 index b7e49e0b91..0000000000 --- a/src/Umbraco.Web/PublishedCache/PublishedContentCacheResolver.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Umbraco.Core.ObjectResolution; - -namespace Umbraco.Web.PublishedCache -{ - /// - /// Resolves the IPublishedContentCache object. - /// - internal sealed class PublishedContentCacheResolver : SingleObjectResolverBase - { - /// - /// Initializes a new instance of the class with a content cache. - /// - /// The content cache. - /// The resolver is created by the WebBootManager and thus the constructor remains internal. - internal PublishedContentCacheResolver(IPublishedContentCache publishedContentCache) - : base(publishedContentCache) - { } - - /// - /// Sets the content cache. - /// - /// The content cache. - /// For developers, at application startup. - public void SetContentCache(IPublishedContentCache contentCache) - { - Value = contentCache; - } - - /// - /// Gets the content cache. - /// - public IPublishedContentCache ContentCache - { - get { return Value; } - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/PublishedCache/PublishedMediaCacheResolver.cs b/src/Umbraco.Web/PublishedCache/PublishedMediaCacheResolver.cs deleted file mode 100644 index a3a0d47fb6..0000000000 --- a/src/Umbraco.Web/PublishedCache/PublishedMediaCacheResolver.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Umbraco.Core.ObjectResolution; - -namespace Umbraco.Web.PublishedCache -{ - /// - /// Resolves the IPublicMediaCache object. - /// - internal sealed class PublishedMediaCacheResolver : SingleObjectResolverBase - { - /// - /// Initializes a new instance of the class with a media cache. - /// - /// The media cache. - /// The resolver is created by the WebBootManager and thus the constructor remains internal. - internal PublishedMediaCacheResolver(IPublishedMediaCache publishedMediaCache) - : base(publishedMediaCache) - { } - - /// - /// Sets the media cache. - /// - /// The media cache. - /// For developers, at application startup. - public void SetContentCache(IPublishedMediaCache publishedMediaCache) - { - Value = publishedMediaCache; - } - - /// - /// Gets the media cache. - /// - public IPublishedMediaCache PublishedMediaCache - { - get { return Value; } - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index a4f8fd5afa..d6b70cd7b7 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -332,6 +332,9 @@ + + + @@ -369,8 +372,6 @@ - - diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs index 1038df0de5..958b3cb97e 100644 --- a/src/Umbraco.Web/UmbracoContext.cs +++ b/src/Umbraco.Web/UmbracoContext.cs @@ -89,8 +89,8 @@ namespace Umbraco.Web var umbracoContext = new UmbracoContext( httpContext, applicationContext, - PublishedContentCacheResolver.Current.ContentCache, - PublishedMediaCacheResolver.Current.PublishedMediaCache); + PublishedCachesResolver.Current.Caches.ContentCache, + PublishedCachesResolver.Current.Caches.MediaCache); // create the nice urls provider // there's one per request because there are some behavior parameters that can be changed diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs index 3acba327db..0e571b4455 100644 --- a/src/Umbraco.Web/WebBootManager.cs +++ b/src/Umbraco.Web/WebBootManager.cs @@ -20,7 +20,6 @@ using Umbraco.Web.Models; using Umbraco.Web.Mvc; using Umbraco.Web.PropertyEditors; using Umbraco.Web.PublishedCache; -using Umbraco.Web.PublishedCache.XmlPublishedCache; using Umbraco.Web.Routing; using Umbraco.Web.WebApi; using umbraco.BusinessLogic; @@ -277,8 +276,9 @@ namespace Umbraco.Web PropertyEditorValueConvertersResolver.Current.RemoveType(); PropertyEditorValueConvertersResolver.Current.AddType(); - PublishedContentCacheResolver.Current = new PublishedContentCacheResolver(new PublishedContentCache()); - PublishedMediaCacheResolver.Current = new PublishedMediaCacheResolver(new PublishedMediaCache()); + PublishedCachesResolver.Current = new PublishedCachesResolver(new PublishedCaches( + new PublishedCache.XmlPublishedCache.PublishedContentCache(), + new PublishedCache.XmlPublishedCache.PublishedMediaCache())); FilteredControllerFactoriesResolver.Current = new FilteredControllerFactoriesResolver( // add all known factories, devs can then modify this list on application @@ -313,7 +313,8 @@ namespace Umbraco.Web SiteDomainHelperResolver.Current = new SiteDomainHelperResolver(new SiteDomainHelper()); - PublishedContentCache.UnitTesting = _isForTesting; + // ain't that a bit dirty? + PublishedCache.XmlPublishedCache.PublishedContentCache.UnitTesting = _isForTesting; ThumbnailProvidersResolver.Current = new ThumbnailProvidersResolver( PluginManager.Current.ResolveThumbnailProviders());