Refactor IPublishedContent.Parent()

This commit is contained in:
Stephan
2019-04-22 11:59:06 +02:00
parent a996d46b6f
commit 41e14a62c0
24 changed files with 62 additions and 67 deletions

View File

@@ -157,7 +157,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
pathParts.Add(urlSegment);
// move to parent node
n = n.Parent;
n = n.Parent();
if (n != null)
urlSegment = n.UrlSegment(culture);
@@ -206,7 +206,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
// "/foo" fails (looking for "/*/foo") we try also "/foo".
// this does not make much sense anyway esp. if both "/foo/" and "/bar/foo" exist, but
// that's the way it works pre-4.10 and we try to be backward compat for the time being
if (content.Parent == null)
if (content.Parent() == null)
{
var rootNode = GetByRoute(preview, "/", true);
if (rootNode == null)

View File

@@ -325,21 +325,18 @@ namespace Umbraco.Web.PublishedCache.NuCache
#region Tree
/// <inheritdoc />
public override IPublishedContent Parent
public override IPublishedContent Parent()
{
get
// have to use the "current" cache because a PublishedContent can be shared
// amongst many snapshots and other content depend on the snapshots
switch (_contentNode.ContentType.ItemType)
{
// have to use the "current" cache because a PublishedContent can be shared
// amongst many snapshots and other content depend on the snapshots
switch (_contentNode.ContentType.ItemType)
{
case PublishedItemType.Content:
return GetContentById(IsPreviewing, _contentNode.ParentContentId);
case PublishedItemType.Media:
return GetMediaById(IsPreviewing, _contentNode.ParentContentId);
default:
throw new Exception($"Panic: unsupported item type \"{_contentNode.ContentType.ItemType}\".");
}
case PublishedItemType.Content:
return GetContentById(IsPreviewing, _contentNode.ParentContentId);
case PublishedItemType.Media:
return GetMediaById(IsPreviewing, _contentNode.ParentContentId);
default:
throw new Exception($"Panic: unsupported item type \"{_contentNode.ContentType.ItemType}\".");
}
}

View File

@@ -82,7 +82,7 @@ namespace Umbraco.Web.PublishedCache
public override bool IsPublished(string culture = null) => true;
public override IPublishedContent Parent => null;
public override IPublishedContent Parent() => null;
public override IEnumerable<IPublishedContent> Children => Enumerable.Empty<IPublishedContent>();