Refactor IPublishedContent.Children()
This commit is contained in:
@@ -107,7 +107,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// hideTopLevelNode = support legacy stuff, look for /*/path/to/node
|
||||
// else normal, look for /path/to/node
|
||||
content = hideTopLevelNode.Value
|
||||
? GetAtRoot(preview).SelectMany(x => x.Children).FirstOrDefault(x => x.UrlSegment(culture) == parts[0])
|
||||
? GetAtRoot(preview).SelectMany(x => x.Children(culture)).FirstOrDefault(x => x.UrlSegment(culture) == parts[0])
|
||||
: GetAtRoot(preview).FirstOrDefault(x => x.UrlSegment(culture) == parts[0]);
|
||||
content = FollowRoute(content, parts, 1, culture);
|
||||
}
|
||||
@@ -187,7 +187,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
while (content != null && i < parts.Count)
|
||||
{
|
||||
var part = parts[i++];
|
||||
content = content.Children.FirstOrDefault(x =>
|
||||
content = content.Children(culture).FirstOrDefault(x =>
|
||||
{
|
||||
var urlSegment = x.UrlSegment(culture);
|
||||
return urlSegment == part;
|
||||
|
||||
@@ -341,17 +341,18 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<IPublishedContent> Children
|
||||
public override IEnumerable<IPublishedContent> Children(string culture = null)
|
||||
{
|
||||
get
|
||||
{
|
||||
var cache = GetAppropriateCache();
|
||||
if (cache == null || PublishedSnapshotService.CachePublishedContentChildren == false)
|
||||
return GetChildren();
|
||||
// FIXME THIS CANNOT WORK
|
||||
// we cannot cache children this way, they should be a linked list!
|
||||
throw new NotImplementedException();
|
||||
|
||||
// note: ToArray is important here, we want to cache the result, not the function!
|
||||
return (IEnumerable<IPublishedContent>)cache.Get(ChildrenCacheKey, () => GetChildren().ToArray());
|
||||
}
|
||||
var cache = GetAppropriateCache();
|
||||
if (cache == null || PublishedSnapshotService.CachePublishedContentChildren == false)
|
||||
return GetChildren();
|
||||
|
||||
// note: ToArray is important here, we want to cache the result, not the function!
|
||||
return (IEnumerable<IPublishedContent>)cache.Get(ChildrenCacheKey, () => GetChildren().ToArray());
|
||||
}
|
||||
|
||||
private string _childrenCacheKey;
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Umbraco.Web.PublishedCache
|
||||
|
||||
public override IPublishedContent Parent() => null;
|
||||
|
||||
public override IEnumerable<IPublishedContent> Children => Enumerable.Empty<IPublishedContent>();
|
||||
public override IEnumerable<IPublishedContent> Children(string culture = null) => Enumerable.Empty<IPublishedContent>();
|
||||
|
||||
public override IEnumerable<IPublishedProperty> Properties => _properties;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user