From efee4d0c0c3ef20f719cfdc19d8224588be4de19 Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 4 Apr 2013 05:09:26 -0200 Subject: [PATCH] Web.PublishedCache - IPublishedCaches creates contextual caches --- .../PublishedCache/IPublishedCaches.cs | 14 +++++++++++++ .../PublishedCache/PublishedCaches.cs | 20 +++++++++++++++++++ src/Umbraco.Web/UmbracoContext.cs | 4 ++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/PublishedCache/IPublishedCaches.cs b/src/Umbraco.Web/PublishedCache/IPublishedCaches.cs index 21652d9ed2..3125656c79 100644 --- a/src/Umbraco.Web/PublishedCache/IPublishedCaches.cs +++ b/src/Umbraco.Web/PublishedCache/IPublishedCaches.cs @@ -20,5 +20,19 @@ namespace Umbraco.Web.PublishedCache /// Gets the media cache. /// IPublishedMediaCache MediaCache { get; } + + /// + /// Creates a contextual content cache for a specified context. + /// + /// The context. + /// A new contextual content cache for the specified context. + ContextualPublishedContentCache CreateContextualContentCache(UmbracoContext context); + + /// + /// Creates a contextual media cache for a specified context. + /// + /// The context. + /// A new contextual media cache for the specified context. + ContextualPublishedMediaCache CreateContextualMediaCache(UmbracoContext context); } } diff --git a/src/Umbraco.Web/PublishedCache/PublishedCaches.cs b/src/Umbraco.Web/PublishedCache/PublishedCaches.cs index 146677418b..7aa7e2f501 100644 --- a/src/Umbraco.Web/PublishedCache/PublishedCaches.cs +++ b/src/Umbraco.Web/PublishedCache/PublishedCaches.cs @@ -25,5 +25,25 @@ /// Gets the media cache. /// public IPublishedMediaCache MediaCache { get; private set; } + + /// + /// Creates a contextual content cache for a specified context. + /// + /// The context. + /// A new contextual content cache for the specified context. + public ContextualPublishedContentCache CreateContextualContentCache(UmbracoContext context) + { + return new ContextualPublishedContentCache(ContentCache, context); + } + + /// + /// Creates a contextual media cache for a specified context. + /// + /// The context. + /// A new contextual media cache for the specified context. + public ContextualPublishedMediaCache CreateContextualMediaCache(UmbracoContext context) + { + return new ContextualPublishedMediaCache(MediaCache, context); + } } } diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs index d8bcf76fdd..7c5663660a 100644 --- a/src/Umbraco.Web/UmbracoContext.cs +++ b/src/Umbraco.Web/UmbracoContext.cs @@ -135,8 +135,8 @@ namespace Umbraco.Web Application = applicationContext; Security = new WebSecurity(); - ContentCache = new ContextualPublishedContentCache(publishedCaches.ContentCache, this); - MediaCache = new ContextualPublishedMediaCache(publishedCaches.MediaCache, this); + ContentCache = publishedCaches.CreateContextualContentCache(this); + MediaCache = publishedCaches.CreateContextualMediaCache(this); InPreviewMode = preview ?? DetectInPreviewModeFromRequest(); // set the urls...