renamed DynamicDocumentList to DynamicPublishedContentList
simplified some of the DynamicPublishedContent methods to accept Func<IPublishedContent> instead of Func<DynamicPublishedContent>, made the IsHelper method private as this shouldn't be exposed. renamed other objects starting with DynamicDocument to DynamicPublishedContent
This commit is contained in:
@@ -13,7 +13,7 @@ namespace Umbraco.Core.Dynamics
|
||||
return this;
|
||||
}
|
||||
|
||||
public DynamicGrouping(DynamicDocumentList list, string groupBy)
|
||||
public DynamicGrouping(DynamicPublishedContentList list, string groupBy)
|
||||
{
|
||||
Inner =
|
||||
list
|
||||
@@ -21,7 +21,7 @@ namespace Umbraco.Core.Dynamics
|
||||
.Select(node =>
|
||||
{
|
||||
string predicate = groupBy;
|
||||
var internalList = new DynamicDocumentList(new DynamicPublishedContent[] { node });
|
||||
var internalList = new DynamicPublishedContentList(new DynamicPublishedContent[] { node });
|
||||
var query = (IQueryable<object>)internalList.Select(predicate, new object[] { });
|
||||
var key = query.FirstOrDefault();
|
||||
return new
|
||||
|
||||
@@ -20,10 +20,10 @@ namespace Umbraco.Core.Dynamics
|
||||
public class DynamicPublishedContent : DynamicObject, IPublishedContent
|
||||
{
|
||||
private readonly IPublishedContent _publishedContent;
|
||||
private DynamicDocumentList _cachedChildren;
|
||||
private DynamicPublishedContentList _cachedChildren;
|
||||
private readonly ConcurrentDictionary<string, object> _cachedMemberOutput = new ConcurrentDictionary<string, object>();
|
||||
|
||||
internal DynamicDocumentList OwnerList { get; set; }
|
||||
internal DynamicPublishedContentList OwnerList { get; set; }
|
||||
|
||||
#region Constructors
|
||||
|
||||
@@ -56,60 +56,60 @@ namespace Umbraco.Core.Dynamics
|
||||
#region Traversal
|
||||
public DynamicPublishedContent Up()
|
||||
{
|
||||
return DynamicDocumentWalker.Up(this);
|
||||
return DynamicPublishedContentWalker.Up(this);
|
||||
}
|
||||
public DynamicPublishedContent Up(int number)
|
||||
{
|
||||
return DynamicDocumentWalker.Up(this, number);
|
||||
return DynamicPublishedContentWalker.Up(this, number);
|
||||
}
|
||||
public DynamicPublishedContent Up(string nodeTypeAlias)
|
||||
{
|
||||
return DynamicDocumentWalker.Up(this, nodeTypeAlias);
|
||||
return DynamicPublishedContentWalker.Up(this, nodeTypeAlias);
|
||||
}
|
||||
public DynamicPublishedContent Down()
|
||||
{
|
||||
return DynamicDocumentWalker.Down(this);
|
||||
return DynamicPublishedContentWalker.Down(this);
|
||||
}
|
||||
public DynamicPublishedContent Down(int number)
|
||||
{
|
||||
return DynamicDocumentWalker.Down(this, number);
|
||||
return DynamicPublishedContentWalker.Down(this, number);
|
||||
}
|
||||
public DynamicPublishedContent Down(string nodeTypeAlias)
|
||||
{
|
||||
return DynamicDocumentWalker.Down(this, nodeTypeAlias);
|
||||
return DynamicPublishedContentWalker.Down(this, nodeTypeAlias);
|
||||
}
|
||||
public DynamicPublishedContent Next()
|
||||
{
|
||||
return DynamicDocumentWalker.Next(this);
|
||||
return DynamicPublishedContentWalker.Next(this);
|
||||
}
|
||||
public DynamicPublishedContent Next(int number)
|
||||
{
|
||||
return DynamicDocumentWalker.Next(this, number);
|
||||
return DynamicPublishedContentWalker.Next(this, number);
|
||||
}
|
||||
public DynamicPublishedContent Next(string nodeTypeAlias)
|
||||
{
|
||||
return DynamicDocumentWalker.Next(this, nodeTypeAlias);
|
||||
return DynamicPublishedContentWalker.Next(this, nodeTypeAlias);
|
||||
}
|
||||
|
||||
public DynamicPublishedContent Previous()
|
||||
{
|
||||
return DynamicDocumentWalker.Previous(this);
|
||||
return DynamicPublishedContentWalker.Previous(this);
|
||||
}
|
||||
public DynamicPublishedContent Previous(int number)
|
||||
{
|
||||
return DynamicDocumentWalker.Previous(this, number);
|
||||
return DynamicPublishedContentWalker.Previous(this, number);
|
||||
}
|
||||
public DynamicPublishedContent Previous(string nodeTypeAlias)
|
||||
{
|
||||
return DynamicDocumentWalker.Previous(this, nodeTypeAlias);
|
||||
return DynamicPublishedContentWalker.Previous(this, nodeTypeAlias);
|
||||
}
|
||||
public DynamicPublishedContent Sibling(int number)
|
||||
{
|
||||
return DynamicDocumentWalker.Sibling(this, number);
|
||||
return DynamicPublishedContentWalker.Sibling(this, number);
|
||||
}
|
||||
public DynamicPublishedContent Sibling(string nodeTypeAlias)
|
||||
{
|
||||
return DynamicDocumentWalker.Sibling(this, nodeTypeAlias);
|
||||
return DynamicPublishedContentWalker.Sibling(this, nodeTypeAlias);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -237,11 +237,11 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
if (result is IEnumerable<IPublishedContent>)
|
||||
{
|
||||
result = new DynamicDocumentList((IEnumerable<IPublishedContent>)result);
|
||||
result = new DynamicPublishedContentList((IEnumerable<IPublishedContent>)result);
|
||||
}
|
||||
if (result is IEnumerable<DynamicPublishedContent>)
|
||||
{
|
||||
result = new DynamicDocumentList((IEnumerable<DynamicPublishedContent>)result);
|
||||
result = new DynamicPublishedContentList((IEnumerable<DynamicPublishedContent>)result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -289,7 +289,7 @@ namespace Umbraco.Core.Dynamics
|
||||
if (filteredTypeChildren.Any())
|
||||
{
|
||||
return new Attempt<object>(true,
|
||||
new DynamicDocumentList(filteredTypeChildren.Select(x => new DynamicPublishedContent(x))));
|
||||
new DynamicPublishedContentList(filteredTypeChildren.Select(x => new DynamicPublishedContent(x))));
|
||||
}
|
||||
return Attempt<object>.False;
|
||||
}
|
||||
@@ -342,7 +342,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
|
||||
//get the data type id for the current property
|
||||
var dataType = DynamicDocumentDataSourceResolver.Current.DataSource.GetDataType(userProperty.DocumentTypeAlias, userProperty.Alias);
|
||||
var dataType = DynamicPublishedContentDataSourceResolver.Current.DataSource.GetDataType(userProperty.DocumentTypeAlias, userProperty.Alias);
|
||||
|
||||
//convert the string value to a known type
|
||||
var converted = ConvertPropertyValue(result, dataType, userProperty.DocumentTypeAlias, userProperty.Alias);
|
||||
@@ -680,13 +680,13 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
return AncestorOrSelf(node => node.DocumentTypeAlias == nodeTypeAlias);
|
||||
}
|
||||
public DynamicPublishedContent AncestorOrSelf(Func<DynamicPublishedContent, bool> func)
|
||||
public DynamicPublishedContent AncestorOrSelf(Func<IPublishedContent, bool> func)
|
||||
{
|
||||
var node = this;
|
||||
while (node != null)
|
||||
{
|
||||
if (func(node)) return node;
|
||||
DynamicPublishedContent parent = node.Parent;
|
||||
var parent = node.Parent;
|
||||
if (parent != null)
|
||||
{
|
||||
if (this != parent)
|
||||
@@ -705,15 +705,15 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
return node;
|
||||
}
|
||||
public DynamicDocumentList AncestorsOrSelf(Func<DynamicPublishedContent, bool> func)
|
||||
public DynamicPublishedContentList AncestorsOrSelf(Func<IPublishedContent, bool> func)
|
||||
{
|
||||
var ancestorList = new List<DynamicPublishedContent>();
|
||||
var ancestorList = new List<IPublishedContent>();
|
||||
var node = this;
|
||||
ancestorList.Add(node);
|
||||
while (node != null)
|
||||
{
|
||||
if (node.Level == 1) break;
|
||||
DynamicPublishedContent parent = node.Parent;
|
||||
var parent = node.Parent;
|
||||
if (parent != null)
|
||||
{
|
||||
if (this != parent)
|
||||
@@ -735,50 +735,50 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
}
|
||||
ancestorList.Reverse();
|
||||
return new DynamicDocumentList(ancestorList);
|
||||
return new DynamicPublishedContentList(ancestorList);
|
||||
}
|
||||
public DynamicDocumentList AncestorsOrSelf()
|
||||
public DynamicPublishedContentList AncestorsOrSelf()
|
||||
{
|
||||
return AncestorsOrSelf(n => true);
|
||||
}
|
||||
public DynamicDocumentList AncestorsOrSelf(string nodeTypeAlias)
|
||||
public DynamicPublishedContentList AncestorsOrSelf(string nodeTypeAlias)
|
||||
{
|
||||
return AncestorsOrSelf(n => n.DocumentTypeAlias == nodeTypeAlias);
|
||||
}
|
||||
public DynamicDocumentList AncestorsOrSelf(int level)
|
||||
public DynamicPublishedContentList AncestorsOrSelf(int level)
|
||||
{
|
||||
return AncestorsOrSelf(n => n.Level <= level);
|
||||
}
|
||||
public DynamicDocumentList Descendants(string nodeTypeAlias)
|
||||
public DynamicPublishedContentList Descendants(string nodeTypeAlias)
|
||||
{
|
||||
return Descendants(p => p.DocumentTypeAlias == nodeTypeAlias);
|
||||
}
|
||||
public DynamicDocumentList Descendants(int level)
|
||||
public DynamicPublishedContentList Descendants(int level)
|
||||
{
|
||||
return Descendants(p => p.Level >= level);
|
||||
}
|
||||
public DynamicDocumentList Descendants()
|
||||
public DynamicPublishedContentList Descendants()
|
||||
{
|
||||
return Descendants(n => true);
|
||||
}
|
||||
internal DynamicDocumentList Descendants(Func<IPublishedContent, bool> func)
|
||||
internal DynamicPublishedContentList Descendants(Func<IPublishedContent, bool> func)
|
||||
{
|
||||
var flattenedNodes = this._publishedContent.Children.Map(func, (IPublishedContent n) => n.Children);
|
||||
return new DynamicDocumentList(flattenedNodes.ToList().ConvertAll(dynamicBackingItem => new DynamicPublishedContent(dynamicBackingItem)));
|
||||
return new DynamicPublishedContentList(flattenedNodes.ToList().ConvertAll(dynamicBackingItem => new DynamicPublishedContent(dynamicBackingItem)));
|
||||
}
|
||||
public DynamicDocumentList DescendantsOrSelf(int level)
|
||||
public DynamicPublishedContentList DescendantsOrSelf(int level)
|
||||
{
|
||||
return DescendantsOrSelf(p => p.Level >= level);
|
||||
}
|
||||
public DynamicDocumentList DescendantsOrSelf(string nodeTypeAlias)
|
||||
public DynamicPublishedContentList DescendantsOrSelf(string nodeTypeAlias)
|
||||
{
|
||||
return DescendantsOrSelf(p => p.DocumentTypeAlias == nodeTypeAlias);
|
||||
}
|
||||
public DynamicDocumentList DescendantsOrSelf()
|
||||
public DynamicPublishedContentList DescendantsOrSelf()
|
||||
{
|
||||
return DescendantsOrSelf(p => true);
|
||||
}
|
||||
internal DynamicDocumentList DescendantsOrSelf(Func<IPublishedContent, bool> func)
|
||||
internal DynamicPublishedContentList DescendantsOrSelf(Func<IPublishedContent, bool> func)
|
||||
{
|
||||
if (this._publishedContent != null)
|
||||
{
|
||||
@@ -788,30 +788,30 @@ namespace Umbraco.Core.Dynamics
|
||||
thisNode.Add(this._publishedContent);
|
||||
}
|
||||
var flattenedNodes = this._publishedContent.Children.Map(func, (IPublishedContent n) => n.Children);
|
||||
return new DynamicDocumentList(thisNode.Concat(flattenedNodes).ToList().ConvertAll(dynamicBackingItem => new DynamicPublishedContent(dynamicBackingItem)));
|
||||
return new DynamicPublishedContentList(thisNode.Concat(flattenedNodes).ToList().ConvertAll(dynamicBackingItem => new DynamicPublishedContent(dynamicBackingItem)));
|
||||
}
|
||||
return new DynamicDocumentList(Enumerable.Empty<IPublishedContent>());
|
||||
return new DynamicPublishedContentList(Enumerable.Empty<IPublishedContent>());
|
||||
}
|
||||
public DynamicDocumentList Ancestors(int level)
|
||||
public DynamicPublishedContentList Ancestors(int level)
|
||||
{
|
||||
return Ancestors(n => n.Level <= level);
|
||||
}
|
||||
public DynamicDocumentList Ancestors(string nodeTypeAlias)
|
||||
public DynamicPublishedContentList Ancestors(string nodeTypeAlias)
|
||||
{
|
||||
return Ancestors(n => n.DocumentTypeAlias == nodeTypeAlias);
|
||||
}
|
||||
public DynamicDocumentList Ancestors()
|
||||
public DynamicPublishedContentList Ancestors()
|
||||
{
|
||||
return Ancestors(n => true);
|
||||
}
|
||||
public DynamicDocumentList Ancestors(Func<DynamicPublishedContent, bool> func)
|
||||
public DynamicPublishedContentList Ancestors(Func<IPublishedContent, bool> func)
|
||||
{
|
||||
var ancestorList = new List<DynamicPublishedContent>();
|
||||
var ancestorList = new List<IPublishedContent>();
|
||||
var node = this;
|
||||
while (node != null)
|
||||
{
|
||||
if (node.Level == 1) break;
|
||||
DynamicPublishedContent parent = node.Parent;
|
||||
var parent = node.Parent;
|
||||
if (parent != null)
|
||||
{
|
||||
if (this != parent)
|
||||
@@ -833,7 +833,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
}
|
||||
ancestorList.Reverse();
|
||||
return new DynamicDocumentList(ancestorList);
|
||||
return new DynamicPublishedContentList(ancestorList);
|
||||
}
|
||||
public DynamicPublishedContent Parent
|
||||
{
|
||||
@@ -956,11 +956,11 @@ namespace Umbraco.Core.Dynamics
|
||||
//testing, think this must be a special case for the root node ?
|
||||
if (!children.Any() && _publishedContent.Id == 0)
|
||||
{
|
||||
_cachedChildren = new DynamicDocumentList(new List<DynamicPublishedContent> { new DynamicPublishedContent(this._publishedContent) });
|
||||
_cachedChildren = new DynamicPublishedContentList(new List<DynamicPublishedContent> { new DynamicPublishedContent(this._publishedContent) });
|
||||
}
|
||||
else
|
||||
{
|
||||
_cachedChildren = new DynamicDocumentList(_publishedContent.Children.Select(x => new DynamicPublishedContent(x)));
|
||||
_cachedChildren = new DynamicPublishedContentList(_publishedContent.Children.Select(x => new DynamicPublishedContent(x)));
|
||||
}
|
||||
}
|
||||
return _cachedChildren;
|
||||
@@ -1042,7 +1042,7 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
//var list = this.Parent.Children.Select(n => new DynamicNode(n));
|
||||
var list = this.Parent.Children;
|
||||
this.OwnerList = new DynamicDocumentList(list);
|
||||
this.OwnerList = new DynamicPublishedContentList(list);
|
||||
}
|
||||
if (this.OwnerList != null)
|
||||
{
|
||||
@@ -1357,15 +1357,15 @@ namespace Umbraco.Core.Dynamics
|
||||
var descendants = this.DescendantsOrSelf();
|
||||
return IsHelper(n => descendants.Items.Find(descendant => descendant.Id == other.Id) != null, valueIfTrue, valueIfFalse);
|
||||
}
|
||||
public bool IsHelper(Func<DynamicPublishedContent, bool> test)
|
||||
private bool IsHelper(Func<DynamicPublishedContent, bool> test)
|
||||
{
|
||||
return test(this);
|
||||
}
|
||||
public HtmlString IsHelper(Func<DynamicPublishedContent, bool> test, string valueIfTrue)
|
||||
private HtmlString IsHelper(Func<DynamicPublishedContent, bool> test, string valueIfTrue)
|
||||
{
|
||||
return IsHelper(test, valueIfTrue, string.Empty);
|
||||
}
|
||||
public HtmlString IsHelper(Func<DynamicPublishedContent, bool> test, string valueIfTrue, string valueIfFalse)
|
||||
private HtmlString IsHelper(Func<DynamicPublishedContent, bool> test, string valueIfTrue, string valueIfFalse)
|
||||
{
|
||||
return test(this) ? new HtmlString(valueIfTrue) : new HtmlString(valueIfFalse);
|
||||
}
|
||||
@@ -1388,7 +1388,7 @@ namespace Umbraco.Core.Dynamics
|
||||
public bool Where(string predicate)
|
||||
{
|
||||
//Totally gonna cheat here
|
||||
var dynamicDocumentList = new DynamicDocumentList();
|
||||
var dynamicDocumentList = new DynamicPublishedContentList();
|
||||
dynamicDocumentList.Add(this);
|
||||
var filtered = dynamicDocumentList.Where<DynamicPublishedContent>(predicate);
|
||||
if (Queryable.Count(filtered) == 1)
|
||||
|
||||
@@ -7,11 +7,11 @@ namespace Umbraco.Core.Dynamics
|
||||
/// and currently the business logic part of Umbraco is still in the legacy project and we don't want to move that to the core so in the
|
||||
/// meantime until the new APIs are made, we need to have this data source in place with a resolver which is set in the web project.
|
||||
/// </summary>
|
||||
internal class DynamicDocumentDataSourceResolver : SingleObjectResolverBase<DynamicDocumentDataSourceResolver, IDynamicDocumentDataSource>
|
||||
internal class DynamicPublishedContentDataSourceResolver : SingleObjectResolverBase<DynamicPublishedContentDataSourceResolver, IDynamicPublishedContentDataSource>
|
||||
{
|
||||
public IDynamicDocumentDataSource DataSource { get; private set; }
|
||||
public IDynamicPublishedContentDataSource DataSource { get; private set; }
|
||||
|
||||
public DynamicDocumentDataSourceResolver(IDynamicDocumentDataSource dataSource)
|
||||
public DynamicPublishedContentDataSourceResolver(IDynamicPublishedContentDataSource dataSource)
|
||||
{
|
||||
DataSource = dataSource;
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
internal class DynamicDocumentIdEqualityComparer : EqualityComparer<DynamicPublishedContent>
|
||||
internal class DynamicPublishedContentIdEqualityComparer : EqualityComparer<DynamicPublishedContent>
|
||||
{
|
||||
|
||||
public override bool Equals(DynamicPublishedContent x, DynamicPublishedContent y)
|
||||
@@ -9,22 +9,22 @@ using System.Reflection;
|
||||
|
||||
namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
public class DynamicDocumentList : DynamicObject, IEnumerable<DynamicPublishedContent>
|
||||
public class DynamicPublishedContentList : DynamicObject, IEnumerable<DynamicPublishedContent>
|
||||
{
|
||||
internal List<DynamicPublishedContent> Items { get; set; }
|
||||
|
||||
public DynamicDocumentList()
|
||||
public DynamicPublishedContentList()
|
||||
{
|
||||
Items = new List<DynamicPublishedContent>();
|
||||
}
|
||||
public DynamicDocumentList(IEnumerable<DynamicPublishedContent> items)
|
||||
public DynamicPublishedContentList(IEnumerable<DynamicPublishedContent> items)
|
||||
{
|
||||
List<DynamicPublishedContent> list = items.ToList();
|
||||
list.ForEach(node => node.OwnerList = this);
|
||||
Items = list;
|
||||
}
|
||||
|
||||
public DynamicDocumentList(IEnumerable<IPublishedContent> items)
|
||||
public DynamicPublishedContentList(IEnumerable<IPublishedContent> items)
|
||||
{
|
||||
List<DynamicPublishedContent> list = items.Select(x => new DynamicPublishedContent(x)).ToList();
|
||||
list.ForEach(node => node.OwnerList = this);
|
||||
@@ -61,24 +61,24 @@ namespace Umbraco.Core.Dynamics
|
||||
var values = args.Skip(1).ToArray();
|
||||
//TODO: We are pre-resolving the where into a ToList() here which will have performance impacts if there where clauses
|
||||
// are nested! We should somehow support an QueryableDocumentList!
|
||||
result = new DynamicDocumentList(this.Where<DynamicPublishedContent>(predicate, values).ToList());
|
||||
result = new DynamicPublishedContentList(this.Where<DynamicPublishedContent>(predicate, values).ToList());
|
||||
return true;
|
||||
}
|
||||
if (name == "OrderBy")
|
||||
{
|
||||
//TODO: We are pre-resolving the where into a ToList() here which will have performance impacts if there where clauses
|
||||
// are nested! We should somehow support an QueryableDocumentList!
|
||||
result = new DynamicDocumentList(this.OrderBy<DynamicPublishedContent>(args.First().ToString()).ToList());
|
||||
result = new DynamicPublishedContentList(this.OrderBy<DynamicPublishedContent>(args.First().ToString()).ToList());
|
||||
return true;
|
||||
}
|
||||
if (name == "Take")
|
||||
{
|
||||
result = new DynamicDocumentList(this.Take((int)args.First()));
|
||||
result = new DynamicPublishedContentList(this.Take((int)args.First()));
|
||||
return true;
|
||||
}
|
||||
if (name == "Skip")
|
||||
{
|
||||
result = new DynamicDocumentList(this.Skip((int)args.First()));
|
||||
result = new DynamicPublishedContentList(this.Skip((int)args.First()));
|
||||
return true;
|
||||
}
|
||||
if (name == "InGroupsOf")
|
||||
@@ -117,12 +117,12 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
if ((args.First() as IEnumerable<DynamicPublishedContent>) != null)
|
||||
{
|
||||
result = new DynamicDocumentList(this.Items.Union(args.First() as IEnumerable<DynamicPublishedContent>));
|
||||
result = new DynamicPublishedContentList(this.Items.Union(args.First() as IEnumerable<DynamicPublishedContent>));
|
||||
return true;
|
||||
}
|
||||
if ((args.First() as DynamicDocumentList) != null)
|
||||
if ((args.First() as DynamicPublishedContentList) != null)
|
||||
{
|
||||
result = new DynamicDocumentList(this.Items.Union((args.First() as DynamicDocumentList).Items));
|
||||
result = new DynamicPublishedContentList(this.Items.Union((args.First() as DynamicPublishedContentList).Items));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -130,12 +130,12 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
if ((args.First() as IEnumerable<DynamicPublishedContent>) != null)
|
||||
{
|
||||
result = new DynamicDocumentList(this.Items.Except(args.First() as IEnumerable<DynamicPublishedContent>, new DynamicDocumentIdEqualityComparer()));
|
||||
result = new DynamicPublishedContentList(this.Items.Except(args.First() as IEnumerable<DynamicPublishedContent>, new DynamicPublishedContentIdEqualityComparer()));
|
||||
return true;
|
||||
}
|
||||
if ((args.First() as DynamicDocumentList) != null)
|
||||
if ((args.First() as DynamicPublishedContentList) != null)
|
||||
{
|
||||
result = new DynamicDocumentList(this.Items.Except((args.First() as DynamicDocumentList).Items, new DynamicDocumentIdEqualityComparer()));
|
||||
result = new DynamicPublishedContentList(this.Items.Except((args.First() as DynamicPublishedContentList).Items, new DynamicPublishedContentIdEqualityComparer()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -143,18 +143,18 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
if ((args.First() as IEnumerable<DynamicPublishedContent>) != null)
|
||||
{
|
||||
result = new DynamicDocumentList(this.Items.Intersect(args.First() as IEnumerable<DynamicPublishedContent>, new DynamicDocumentIdEqualityComparer()));
|
||||
result = new DynamicPublishedContentList(this.Items.Intersect(args.First() as IEnumerable<DynamicPublishedContent>, new DynamicPublishedContentIdEqualityComparer()));
|
||||
return true;
|
||||
}
|
||||
if ((args.First() as DynamicDocumentList) != null)
|
||||
if ((args.First() as DynamicPublishedContentList) != null)
|
||||
{
|
||||
result = new DynamicDocumentList(this.Items.Intersect((args.First() as DynamicDocumentList).Items, new DynamicDocumentIdEqualityComparer()));
|
||||
result = new DynamicPublishedContentList(this.Items.Intersect((args.First() as DynamicPublishedContentList).Items, new DynamicPublishedContentIdEqualityComparer()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (name == "Distinct")
|
||||
{
|
||||
result = new DynamicDocumentList(this.Items.Distinct(new DynamicDocumentIdEqualityComparer()));
|
||||
result = new DynamicPublishedContentList(this.Items.Distinct(new DynamicPublishedContentIdEqualityComparer()));
|
||||
return true;
|
||||
}
|
||||
if (name == "Pluck" || name == "Select")
|
||||
@@ -369,7 +369,7 @@ namespace Umbraco.Core.Dynamics
|
||||
var methodTypesToFind = new[]
|
||||
{
|
||||
typeof(IEnumerable<DynamicPublishedContent>),
|
||||
typeof(DynamicDocumentList)
|
||||
typeof(DynamicPublishedContentList)
|
||||
};
|
||||
|
||||
//find known extension methods that match the first type in the list
|
||||
@@ -383,7 +383,7 @@ namespace Umbraco.Core.Dynamics
|
||||
|
||||
if (toExecute != null)
|
||||
{
|
||||
if (toExecute.GetParameters().First().ParameterType == typeof(DynamicDocumentList))
|
||||
if (toExecute.GetParameters().First().ParameterType == typeof(DynamicPublishedContentList))
|
||||
{
|
||||
var genericArgs = (new[] { this }).Concat(args);
|
||||
result = toExecute.Invoke(null, genericArgs.ToArray());
|
||||
@@ -412,11 +412,11 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
if (result is IEnumerable<IPublishedContent>)
|
||||
{
|
||||
result = new DynamicDocumentList((IEnumerable<IPublishedContent>)result);
|
||||
result = new DynamicPublishedContentList((IEnumerable<IPublishedContent>)result);
|
||||
}
|
||||
if (result is IEnumerable<DynamicPublishedContent>)
|
||||
{
|
||||
result = new DynamicDocumentList((IEnumerable<DynamicPublishedContent>)result);
|
||||
result = new DynamicPublishedContentList((IEnumerable<DynamicPublishedContent>)result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -5,7 +5,7 @@ using System.Linq.Expressions;
|
||||
|
||||
namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
internal static class DynamicDocumentListOrdering
|
||||
internal static class DynamicPublishedContentListOrdering
|
||||
{
|
||||
|
||||
private static TOut Reduce<TOut>(Func<DynamicPublishedContent, TOut> func, DynamicPublishedContent publishedContent)
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
|
||||
namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
internal static class DynamicDocumentWalker
|
||||
internal static class DynamicPublishedContentWalker
|
||||
{
|
||||
public static DynamicPublishedContent Up(this DynamicPublishedContent context)
|
||||
{
|
||||
@@ -41,7 +41,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
public static DynamicPublishedContent Down(this DynamicPublishedContent context, int number)
|
||||
{
|
||||
var children = new DynamicDocumentList(context.Children);
|
||||
var children = new DynamicPublishedContentList(context.Children);
|
||||
if (number == 0)
|
||||
{
|
||||
return children.Items.First();
|
||||
@@ -52,7 +52,7 @@ namespace Umbraco.Core.Dynamics
|
||||
while (number-- >= 0)
|
||||
{
|
||||
working = children.Items.First();
|
||||
children = new DynamicDocumentList(working.Children);
|
||||
children = new DynamicPublishedContentList(working.Children);
|
||||
}
|
||||
return working;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ namespace Umbraco.Core.Dynamics
|
||||
|
||||
if (string.IsNullOrEmpty(nodeTypeAlias))
|
||||
{
|
||||
var children = new DynamicDocumentList(context.Children);
|
||||
var children = new DynamicPublishedContentList(context.Children);
|
||||
return children.Items.First();
|
||||
}
|
||||
else
|
||||
@@ -80,7 +80,7 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
//var list = context.Parent.Children.Select(n => new DynamicNode(n));
|
||||
var list = context.Parent.Children;
|
||||
context.OwnerList = new DynamicDocumentList(list);
|
||||
context.OwnerList = new DynamicPublishedContentList(list);
|
||||
}
|
||||
if (context.OwnerList != null)
|
||||
{
|
||||
@@ -106,7 +106,7 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
//var list = context.Parent.Children.Select(n => new DynamicNode(n));
|
||||
var list = context.Parent.Children;
|
||||
context.OwnerList = new DynamicDocumentList(list);
|
||||
context.OwnerList = new DynamicPublishedContentList(list);
|
||||
}
|
||||
if (context.OwnerList != null)
|
||||
{
|
||||
@@ -132,7 +132,7 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
//var list = context.Parent.Children.Select(n => new DynamicNode(n));
|
||||
var list = context.Parent.Children;
|
||||
context.OwnerList = new DynamicDocumentList(list);
|
||||
context.OwnerList = new DynamicPublishedContentList(list);
|
||||
}
|
||||
if (context.OwnerList != null)
|
||||
{
|
||||
@@ -172,7 +172,7 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
//var list = context.Parent.Children.Select(n => new DynamicNode(n));
|
||||
var list = context.Parent.Children;
|
||||
context.OwnerList = new DynamicDocumentList(list);
|
||||
context.OwnerList = new DynamicPublishedContentList(list);
|
||||
}
|
||||
if (context.OwnerList != null)
|
||||
{
|
||||
@@ -207,7 +207,7 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
//var list = context.Parent.Children.Select(n => new DynamicNode(n));
|
||||
var list = context.Parent.Children;
|
||||
context.OwnerList = new DynamicDocumentList(list);
|
||||
context.OwnerList = new DynamicPublishedContentList(list);
|
||||
}
|
||||
if (context.OwnerList != null)
|
||||
{
|
||||
@@ -233,7 +233,7 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
//var list = context.Parent.Children.Select(n => new DynamicNode(n));
|
||||
var list = context.Parent.Children;
|
||||
context.OwnerList = new DynamicDocumentList(list);
|
||||
context.OwnerList = new DynamicPublishedContentList(list);
|
||||
}
|
||||
if (context.OwnerList != null)
|
||||
{
|
||||
@@ -214,7 +214,7 @@ namespace Umbraco.Core.Dynamics
|
||||
//reroute each stacked Expression.Call into our own methods that know how to deal
|
||||
//with DynamicNode
|
||||
queryExpr = Expression.Call(
|
||||
typeof(DynamicDocumentListOrdering),
|
||||
typeof(DynamicPublishedContentListOrdering),
|
||||
o.Ascending ? methodAsc : methodDesc,
|
||||
null,
|
||||
queryExpr,
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
|
||||
|
||||
public static DynamicDocumentList Random(this DynamicDocumentList all, int min, int max)
|
||||
public static DynamicPublishedContentList Random(this DynamicPublishedContentList all, int min, int max)
|
||||
{
|
||||
//get a random number generator
|
||||
Random r = new Random();
|
||||
@@ -41,13 +41,13 @@ namespace Umbraco.Core.Dynamics
|
||||
//Call the other method
|
||||
return Random(all, Number);
|
||||
}
|
||||
public static DynamicDocumentList Random(this DynamicDocumentList all, int max)
|
||||
public static DynamicPublishedContentList Random(this DynamicPublishedContentList all, int max)
|
||||
{
|
||||
//Randomly order the items in the set by a Guid, Take the correct number, and return this wrapped in a new DynamicNodeList
|
||||
return new DynamicDocumentList(all.Items.OrderBy(x => Guid.NewGuid()).Take(max));
|
||||
return new DynamicPublishedContentList(all.Items.OrderBy(x => Guid.NewGuid()).Take(max));
|
||||
}
|
||||
|
||||
public static DynamicPublishedContent Random(this DynamicDocumentList all)
|
||||
public static DynamicPublishedContent Random(this DynamicPublishedContentList all)
|
||||
{
|
||||
return all.Items.OrderBy(x => Guid.NewGuid()).First();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Umbraco.Core.Dynamics
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
var temp = new DynamicDocumentList(Elements.Cast<DynamicPublishedContent>());
|
||||
var temp = new DynamicPublishedContentList(Elements.Cast<DynamicPublishedContent>());
|
||||
return (IEnumerator<T>)temp.GetEnumerator();
|
||||
}
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
@@ -21,7 +21,7 @@ namespace Umbraco.Core.Dynamics
|
||||
return (IEnumerator)GetEnumerator();
|
||||
}
|
||||
|
||||
public DynamicDocumentList OrderBy(string ordering)
|
||||
public DynamicPublishedContentList OrderBy(string ordering)
|
||||
{
|
||||
bool descending = false;
|
||||
if (ordering.IndexOf(" descending", StringComparison.CurrentCultureIgnoreCase) >= 0)
|
||||
@@ -37,7 +37,7 @@ namespace Umbraco.Core.Dynamics
|
||||
|
||||
if (!descending)
|
||||
{
|
||||
return new DynamicDocumentList(Elements.OrderBy(item =>
|
||||
return new DynamicPublishedContentList(Elements.OrderBy(item =>
|
||||
{
|
||||
object key = null;
|
||||
(item as DynamicObject).TryGetMember(new DynamicQueryableGetMemberBinder(ordering, false), out key);
|
||||
@@ -46,7 +46,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
else
|
||||
{
|
||||
return new DynamicDocumentList(Elements.OrderByDescending(item =>
|
||||
return new DynamicPublishedContentList(Elements.OrderByDescending(item =>
|
||||
{
|
||||
object key = null;
|
||||
(item as DynamicObject).TryGetMember(new DynamicQueryableGetMemberBinder(ordering, false), out key);
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Umbraco.Core.Dynamics
|
||||
/// and currently the business logic part of Umbraco is still in the legacy project and we don't want to move that to the core so in the
|
||||
/// meantime until the new APIs are made, we need to have this data source in place with a resolver which is set in the web project.
|
||||
/// </summary>
|
||||
internal interface IDynamicDocumentDataSource
|
||||
internal interface IDynamicPublishedContentDataSource
|
||||
{
|
||||
Guid GetDataType(string docTypeAlias, string propertyAlias);
|
||||
|
||||
Reference in New Issue
Block a user