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. /// internal class ContextualPublishedContentCache : ContextualPublishedCache { private readonly IPublishedContentCache _cache; /// /// Initializes a new instance of the class with a published content cache and a context. /// /// A published content cache. /// A context. public ContextualPublishedContentCache(IPublishedContentCache cache, UmbracoContext umbracoContext) : base(umbracoContext) { _cache = cache; } /// /// Gets a content identified by its unique identifier. /// /// The content unique identifier. /// The content, or null. public override IPublishedContent GetById(int contentId) { return _cache.GetById(UmbracoContext, contentId); } /// /// Gets contents at root. /// /// The contents. public override IEnumerable GetAtRoot() { return _cache.GetAtRoot(UmbracoContext); } /// /// Gets a content resulting from an XPath query. /// /// The XPath query. /// Optional XPath variables. /// The content, or null. public override IPublishedContent GetSingleByXPath(string xpath, Core.Xml.XPathVariable[] vars) { return _cache.GetSingleByXPath(UmbracoContext, xpath, vars); } /// /// Gets contents resulting from an XPath query. /// /// The XPath query. /// Optional XPath variables. /// The contents. public override IEnumerable GetByXPath(string xpath, Core.Xml.XPathVariable[] vars) { return _cache.GetByXPath(UmbracoContext, xpath, vars); } // FIXME do we want that one here? public IPublishedContent GetByRoute(string route, bool? hideTopLevelNode = null) { return _cache.GetByRoute(UmbracoContext, route, hideTopLevelNode); } // FIXME do we want that one here? public IPublishedContent GetByUrlAlias(int rootNodeId, string alias) { return _cache.GetByUrlAlias(UmbracoContext, rootNodeId, alias); } /// /// Gets a value indicating whether the underlying non-contextual cache contains published content. /// /// The context. /// A value indicating whether the underlying non-contextual cache contains published content. public bool HasContent(UmbracoContext umbracoContext) { return _cache.HasContent(umbracoContext); } } }