2013-03-19 17:51:55 -01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using Umbraco.Core.Models;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.PublishedCache
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Provides access to cached documents in a specified context.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class ContextualPublishedContentCache : ContextualPublishedCache
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IPublishedContentCache _cache;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="ContextualPublishedContentCache"/> class with a published content cache and a context.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="cache">A published content cache.</param>
|
|
|
|
|
|
/// <param name="umbracoContext">A context.</param>
|
|
|
|
|
|
public ContextualPublishedContentCache(IPublishedContentCache cache, UmbracoContext umbracoContext)
|
2013-03-20 16:01:49 -01:00
|
|
|
|
: base(umbracoContext, cache)
|
2013-03-19 17:51:55 -01:00
|
|
|
|
{
|
|
|
|
|
|
_cache = cache;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-19 17:54:41 -01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the inner IPublishedContentCache.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <remarks>For unit tests.</remarks>
|
|
|
|
|
|
internal IPublishedContentCache InnerCache { get { return _cache; } }
|
|
|
|
|
|
|
2013-03-19 17:51:55 -01:00
|
|
|
|
/// <summary>
|
2013-03-20 16:01:49 -01:00
|
|
|
|
/// Gets content identified by a route.
|
2013-03-19 17:51:55 -01:00
|
|
|
|
/// </summary>
|
2013-03-20 16:01:49 -01:00
|
|
|
|
/// <param name="route">The route</param>
|
2013-03-21 08:54:25 -01:00
|
|
|
|
/// <param name="hideTopLevelNode">A value forcing the HideTopLevelNode setting.</param>
|
2013-03-19 17:51:55 -01:00
|
|
|
|
/// <returns>The content, or null.</returns>
|
2013-03-20 16:01:49 -01:00
|
|
|
|
/// <remarks>A valid route is either a simple path eg <c>/foo/bar/nil</c> or a root node id and a path, eg <c>123/foo/bar/nil</c>.</remarks>
|
|
|
|
|
|
public IPublishedContent GetByRoute(string route, bool? hideTopLevelNode = null)
|
2013-03-19 17:51:55 -01:00
|
|
|
|
{
|
2013-03-20 16:01:49 -01:00
|
|
|
|
return _cache.GetByRoute(UmbracoContext, route, hideTopLevelNode);
|
2013-03-19 17:51:55 -01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2013-03-20 16:01:49 -01:00
|
|
|
|
/// Gets the route for a content identified by its unique identifier.
|
2013-03-19 17:51:55 -01:00
|
|
|
|
/// </summary>
|
2013-03-20 16:01:49 -01:00
|
|
|
|
/// <param name="contentId">The content unique identifier.</param>
|
|
|
|
|
|
/// <returns>The route.</returns>
|
|
|
|
|
|
public string GetRouteById(int contentId)
|
2013-03-19 17:51:55 -01:00
|
|
|
|
{
|
2013-03-20 16:01:49 -01:00
|
|
|
|
return _cache.GetRouteById(UmbracoContext, contentId);
|
2013-03-19 17:51:55 -01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|