Web.PublishedCache - refactor how caches manage preview

This commit is contained in:
Stephan
2013-03-31 18:47:25 -02:00
parent efee4d0c0c
commit c5b6bb52e0
12 changed files with 213 additions and 102 deletions

View File

@@ -29,13 +29,36 @@ namespace Umbraco.Web.PublishedCache
/// </summary>
/// <param name="contentId">The content unique identifier.</param>
/// <returns>The content, or null.</returns>
public abstract IPublishedContent GetById(int contentId);
/// <remarks>Considers published or unpublished content depending on context.</remarks>
public IPublishedContent GetById(int contentId)
{
return GetById(UmbracoContext.InPreviewMode, contentId);
}
/// <summary>
/// Gets a content identified by its unique identifier.
/// </summary>
/// <param name="preview">A value indicating whether to consider unpublished content.</param>
/// <param name="contentId">The content unique identifier.</param>
/// <returns>The content, or null.</returns>
public abstract IPublishedContent GetById(bool preview, int contentId);
/// <summary>
/// Gets content at root.
/// </summary>
/// <returns>The contents.</returns>
/// <remarks>Considers published or unpublished content depending on context.</remarks>
public IEnumerable<IPublishedContent> GetAtRoot()
{
return GetAtRoot(UmbracoContext.InPreviewMode);
}
/// <summary>
/// Gets contents at root.
/// </summary>
/// <param name="preview">A value indicating whether to consider unpublished content.</param>
/// <returns>The contents.</returns>
public abstract IEnumerable<IPublishedContent> GetAtRoot();
public abstract IEnumerable<IPublishedContent> GetAtRoot(bool preview);
/// <summary>
/// Gets a content resulting from an XPath query.
@@ -47,11 +70,29 @@ namespace Umbraco.Web.PublishedCache
/// <para>If <param name="vars" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// <para>Considers published or unpublished content depending on context.</para>
/// </remarks>
public abstract IPublishedContent GetSingleByXPath(string xpath, params XPathVariable[] vars);
public IPublishedContent GetSingleByXPath(string xpath, params XPathVariable[] vars)
{
return GetSingleByXPath(UmbracoContext.InPreviewMode, xpath, vars);
}
/// <summary>
/// Gets contents resulting from an XPath query.
/// Gets a content resulting from an XPath query.
/// </summary>
/// <param name="preview">A value indicating whether to consider unpublished content.</param>
/// <param name="xpath">The XPath query.</param>
/// <param name="vars">Optional XPath variables.</param>
/// <returns>The content, or null.</returns>
/// <remarks>
/// <para>If <param name="vars" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public abstract IPublishedContent GetSingleByXPath(bool preview, string xpath, params XPathVariable[] vars);
/// <summary>
/// Gets content resulting from an XPath query.
/// </summary>
/// <param name="xpath">The XPath query.</param>
/// <param name="vars">Optional XPath variables.</param>
@@ -60,19 +101,59 @@ namespace Umbraco.Web.PublishedCache
/// <para>If <param name="vars" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// <para>Considers published or unpublished content depending on context.</para>
/// </remarks>
public abstract IEnumerable<IPublishedContent> GetByXPath(string xpath, params XPathVariable[] vars);
public IEnumerable<IPublishedContent> GetByXPath(string xpath, params XPathVariable[] vars)
{
return GetByXPath(UmbracoContext.InPreviewMode, xpath, vars);
}
/// <summary>
/// Gets an XPath navigator that can be used to navigate contents.
/// Gets content resulting from an XPath query.
/// </summary>
/// <param name="preview">A value indicating whether to consider unpublished content.</param>
/// <param name="xpath">The XPath query.</param>
/// <param name="vars">Optional XPath variables.</param>
/// <returns>The contents.</returns>
/// <remarks>
/// <para>If <param name="vars" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public abstract IEnumerable<IPublishedContent> GetByXPath(bool preview, string xpath, params XPathVariable[] vars);
/// <summary>
/// Gets an XPath navigator that can be used to navigate content.
/// </summary>
/// <returns>The XPath navigator.</returns>
public abstract XPathNavigator GetXPathNavigator();
/// <remarks>Considers published or unpublished content depending on context.</remarks>
public XPathNavigator GetXPathNavigator()
{
return GetXPathNavigator(UmbracoContext.InPreviewMode);
}
/// <summary>
/// Gets a value indicating whether the underlying non-contextual cache contains published content.
/// Gets an XPath navigator that can be used to navigate content.
/// </summary>
/// <returns>A value indicating whether the underlying non-contextual cache contains published content.</returns>
public abstract bool HasContent();
/// <param name="preview">A value indicating whether to consider unpublished content.</param>
/// <returns>The XPath navigator.</returns>
public abstract XPathNavigator GetXPathNavigator(bool preview);
/// <summary>
/// Gets a value indicating whether the underlying non-contextual cache contains content.
/// </summary>
/// <returns>A value indicating whether the underlying non-contextual cache contains content.</returns>
/// <remarks>Considers published or unpublished content depending on context.</remarks>
public bool HasContent()
{
return HasContent(UmbracoContext.InPreviewMode);
}
/// <summary>
/// Gets a value indicating whether the underlying non-contextual cache contains content.
/// </summary>
/// <param name="preview">A value indicating whether to consider unpublished content.</param>
/// <returns>A value indicating whether the underlying non-contextual cache contains content.</returns>
public abstract bool HasContent(bool preview);
}
}