using System; using System.Collections.Generic; using System.Linq; using System.Text; using Umbraco.Core.Models; namespace Umbraco.Web.PublishedCache { /// /// Provides access to cached documents in a specified context. /// public class ContextualPublishedContentCache : ContextualPublishedCache { /// /// Initializes a new instance of the class with a published content cache and a context. /// /// A published content cache. /// A context. internal ContextualPublishedContentCache(IPublishedContentCache cache, UmbracoContext umbracoContext) : base(umbracoContext, cache) { } /// /// Gets content identified by a route. /// /// The route /// A value forcing the HideTopLevelNode setting. /// The content, or null. /// /// A valid route is either a simple path eg /foo/bar/nil or a root node id and a path, eg 123/foo/bar/nil. /// Considers published or unpublished content depending on context. /// public IPublishedContent GetByRoute(string route, bool? hideTopLevelNode = null) { return GetByRoute(UmbracoContext.InPreviewMode, route, hideTopLevelNode); } /// /// Gets content identified by a route. /// /// A value indicating whether to consider unpublished content. /// The route /// A value forcing the HideTopLevelNode setting. /// The content, or null. /// A valid route is either a simple path eg /foo/bar/nil or a root node id and a path, eg 123/foo/bar/nil. public IPublishedContent GetByRoute(bool preview, string route, bool? hideTopLevelNode = null) { return InnerCache.GetByRoute(UmbracoContext, preview, route, hideTopLevelNode); } /// /// Gets the route for a content identified by its unique identifier. /// /// The content unique identifier. /// The route. /// Considers published or unpublished content depending on context. public string GetRouteById(int contentId) { return GetRouteById(UmbracoContext.InPreviewMode, contentId); } /// /// Gets the route for a content identified by its unique identifier. /// /// A value indicating whether to consider unpublished content. /// The content unique identifier. /// The route. /// Considers published or unpublished content depending on context. public string GetRouteById(bool preview, int contentId) { return InnerCache.GetRouteById(UmbracoContext, preview, contentId); } } }