Web.PublishedCache - add XPathNavigator support

This commit is contained in:
Stephan
2013-04-03 11:19:10 -02:00
parent 8d33488923
commit 23525300bb
4 changed files with 43 additions and 18 deletions

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Xml;
@@ -42,9 +43,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
if (route == null) throw new ArgumentNullException("route");
// try to get from cache if not previewing
var contentId = umbracoContext.InPreviewMode
? 0
: _routesCache.GetNodeId(route);
var contentId = umbracoContext.InPreviewMode ? 0 : _routesCache.GetNodeId(route);
// if found id in cache then get corresponding content
// and clear cache if not found - for whatever reason
@@ -82,9 +81,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
public virtual string GetRouteById(UmbracoContext umbracoContext, int contentId)
{
// try to get from cache if not previewing
var route = umbracoContext.InPreviewMode
? null
: _routesCache.GetRoute(contentId);
var route = umbracoContext.InPreviewMode ? null : _routesCache.GetRoute(contentId);
// if found in cache then return
if (route != null)
@@ -272,7 +269,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
return ConvertToDocument(GetXml(umbracoContext).GetElementById(nodeId.ToString()));
}
public virtual IEnumerable<IPublishedContent> GetAtRoot(UmbracoContext umbracoContext)
public virtual IEnumerable<IPublishedContent> GetAtRoot(UmbracoContext umbracoContext)
{
return (from XmlNode x in GetXml(umbracoContext).SelectNodes(XPathStrings.RootDocuments) select ConvertToDocument(x)).ToList();
}
@@ -310,6 +307,12 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
return node != null;
}
public virtual XPathNavigator GetXPathNavigator(UmbracoContext umbracoContext)
{
var xml = GetXml(umbracoContext);
return xml.CreateNavigator();
}
#endregion
#region Legacy Xml