Back merged from 6.1 the changes required for #U4-1822 and #U4-1797
This commit is contained in:
@@ -1025,8 +1025,9 @@ namespace umbraco.MacroEngines
|
||||
}
|
||||
public DynamicNodeList Descendants(Func<DynamicBackingItem, bool> func)
|
||||
{
|
||||
var flattenedNodes = this.n.ChildrenAsList.Map(func, (DynamicBackingItem n) => { return n.ChildrenAsList; });
|
||||
return new DynamicNodeList(flattenedNodes.ToList().ConvertAll(DynamicBackingItem => new DynamicNode(DynamicBackingItem)));
|
||||
//var flattenedNodes = this.n.ChildrenAsList.Map(func, (DynamicBackingItem n) => { return n.ChildrenAsList; });
|
||||
var flattenedNodes = this.n.ChildrenAsList.FlattenList(item => item.ChildrenAsList).Where(func);
|
||||
return new DynamicNodeList(flattenedNodes.Select(dynamicBackingItem => new DynamicNode(dynamicBackingItem)));
|
||||
}
|
||||
public DynamicNodeList DescendantsOrSelf(int level)
|
||||
{
|
||||
@@ -1049,8 +1050,9 @@ namespace umbraco.MacroEngines
|
||||
{
|
||||
thisNode.Add(this.n);
|
||||
}
|
||||
var flattenedNodes = this.n.ChildrenAsList.Map(func, (DynamicBackingItem n) => { return n.ChildrenAsList; });
|
||||
return new DynamicNodeList(thisNode.Concat(flattenedNodes).ToList().ConvertAll(DynamicBackingItem => new DynamicNode(DynamicBackingItem)));
|
||||
//var flattenedNodes = this.n.ChildrenAsList.Map(func, (DynamicBackingItem n) => { return n.ChildrenAsList; });
|
||||
var flattenedNodes = this.n.ChildrenAsList.FlattenList(item => item.ChildrenAsList).Where(func);
|
||||
return new DynamicNodeList(thisNode.Concat(flattenedNodes).Select(dynamicBackingItem => new DynamicNode(dynamicBackingItem)));
|
||||
}
|
||||
return new DynamicNodeList(new List<DynamicBackingItem>());
|
||||
}
|
||||
|
||||
@@ -3,18 +3,20 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using Umbraco.Core;
|
||||
|
||||
namespace umbraco.MacroEngines
|
||||
{
|
||||
public static class ExtensionMethods
|
||||
{
|
||||
[Obsolete("This has been superceded by Umbraco.Core.Dynamics.ExtensionMethods.Map method")]
|
||||
[Obsolete("This has been superceded by Umbraco.Core.EnumerableExtensions.FlattenList method")]
|
||||
public static IEnumerable<TSource> Map<TSource>(
|
||||
this IEnumerable<TSource> source,
|
||||
Func<TSource, bool> selectorFunction,
|
||||
Func<TSource, IEnumerable<TSource>> getChildrenFunction)
|
||||
{
|
||||
return Umbraco.Core.Dynamics.ExtensionMethods.Map<TSource>(source, selectorFunction, getChildrenFunction);
|
||||
//return Umbraco.Core.Dynamics.ExtensionMethods.Map<TSource>(source, selectorFunction, getChildrenFunction);
|
||||
return source.FlattenList(getChildrenFunction).Where(selectorFunction);
|
||||
}
|
||||
|
||||
public static DynamicNodeList Random(this DynamicNodeList all, int Min, int Max)
|
||||
|
||||
Reference in New Issue
Block a user