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:
Shannon Deminick
2012-10-02 22:51:53 +05:00
parent f3e04ac871
commit ef5525e67f
28 changed files with 140 additions and 140 deletions
+2 -2
View File
@@ -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();
}
+4 -4
View File
@@ -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);
+6 -6
View File
@@ -69,11 +69,11 @@
<Compile Include="Dynamics\DynamicExpression.cs" />
<Compile Include="Dynamics\DynamicGrouping.cs" />
<Compile Include="Dynamics\DynamicPublishedContent.cs" />
<Compile Include="Dynamics\DynamicDocumentDataSourceResolver.cs" />
<Compile Include="Dynamics\DynamicDocumentIdEqualityComparer.cs" />
<Compile Include="Dynamics\DynamicDocumentList.cs" />
<Compile Include="Dynamics\DynamicDocumentListOrdering.cs" />
<Compile Include="Dynamics\DynamicDocumentWalker.cs" />
<Compile Include="Dynamics\DynamicPublishedContentDataSourceResolver.cs" />
<Compile Include="Dynamics\DynamicPublishedContentIdEqualityComparer.cs" />
<Compile Include="Dynamics\DynamicPublishedContentList.cs" />
<Compile Include="Dynamics\DynamicPublishedContentListOrdering.cs" />
<Compile Include="Dynamics\DynamicPublishedContentWalker.cs" />
<Compile Include="Dynamics\DynamicNull.cs" />
<Compile Include="Dynamics\DynamicOrdering.cs" />
<Compile Include="Dynamics\DynamicProperty.cs" />
@@ -95,7 +95,7 @@
<Compile Include="ObjectResolution\WeightedPluginAttribute.cs" />
<Compile Include="PropertyEditors\DatePickerPropertyEditorValueConverter.cs" />
<Compile Include="PropertyEditors\IPropertyEditorValueConverter.cs" />
<Compile Include="Dynamics\IDynamicDocumentDataSource.cs" />
<Compile Include="Dynamics\IDynamicPublishedContentDataSource.cs" />
<Compile Include="Dynamics\ParseException.cs" />
<Compile Include="Dynamics\PropertyResult.cs" />
<Compile Include="Dynamics\Res.cs" />
@@ -21,7 +21,7 @@ namespace Umbraco.Tests.DynamicDocument
{
base.Initialize();
//need to specify a different callback for testing
Umbraco.Web.DocumentExtensions.GetPropertyAliasesAndNames = s =>
Umbraco.Web.PublishedContentExtensions.GetPropertyAliasesAndNames = s =>
{
var userFields = new Dictionary<string, string>()
{
@@ -64,7 +64,7 @@ namespace Umbraco.Tests.DynamicDocument
public override void TearDown()
{
base.TearDown();
Umbraco.Web.DocumentExtensions.GetPropertyAliasesAndNames = null;
Umbraco.Web.PublishedContentExtensions.GetPropertyAliasesAndNames = null;
UmbracoContext.Current = null;
}
@@ -17,14 +17,14 @@ namespace Umbraco.Tests.DynamicDocument
{
base.Initialize();
DynamicDocumentDataSourceResolver.Current = new DynamicDocumentDataSourceResolver(
new TestDynamicDocumentDataSource());
DynamicPublishedContentDataSourceResolver.Current = new DynamicPublishedContentDataSourceResolver(
new TestDynamicPublishedContentDataSource());
}
public override void TearDown()
{
base.TearDown();
DynamicDocumentDataSourceResolver.Reset();
DynamicPublishedContentDataSourceResolver.Reset();
}
protected override bool RequiresDbSetup
@@ -32,7 +32,7 @@ namespace Umbraco.Tests.DynamicDocument
get { return false; }
}
private class TestDynamicDocumentDataSource : IDynamicDocumentDataSource
private class TestDynamicPublishedContentDataSource : IDynamicPublishedContentDataSource
{
public Guid GetDataType(string docTypeAlias, string propertyAlias)
{
@@ -3,7 +3,7 @@ using Umbraco.Core.Dynamics;
namespace Umbraco.Tests.DynamicDocument
{
public static class DynamicDocumentCustomExtensionMethods
public static class DynamicPublishedContentCustomExtensionMethods
{
public static string DynamicDocumentNoParameters(this Core.Dynamics.DynamicPublishedContent doc)
@@ -21,7 +21,7 @@ namespace Umbraco.Tests.DynamicDocument
return custom + i + b;
}
public static string DynamicDocumentListMultiParam(this DynamicDocumentList doc, string custom, int i, bool b)
public static string DynamicDocumentListMultiParam(this DynamicPublishedContentList doc, string custom, int i, bool b)
{
return custom + i + b;
}
@@ -14,7 +14,7 @@ using umbraco.cms.businesslogic.web;
namespace Umbraco.Tests.DynamicDocument
{
[TestFixture]
public class DynamicDocumentTests : DynamicDocumentTestsBase<Umbraco.Core.Dynamics.DynamicPublishedContent, DynamicDocumentList>
public class DynamicPublishedContentTests : DynamicDocumentTestsBase<Umbraco.Core.Dynamics.DynamicPublishedContent, DynamicPublishedContentList>
{
public override void Initialize()
{
+2 -2
View File
@@ -63,8 +63,8 @@
<Compile Include="BusinessLogic\ApplicationTreeTest.cs" />
<Compile Include="BusinessLogic\BaseTest.cs" />
<Compile Include="CacheRefresherFactoryTests.cs" />
<Compile Include="DynamicDocument\DynamicDocumentCustomExtensionMethods.cs" />
<Compile Include="DynamicDocument\DynamicDocumentTests.cs" />
<Compile Include="DynamicDocument\DynamicPublishedContentCustomExtensionMethods.cs" />
<Compile Include="DynamicDocument\DynamicPublishedContentTests.cs" />
<Compile Include="DynamicDocument\DynamicDocumentTestsBase.cs" />
<Compile Include="DynamicDocument\DynamicNodeTests.cs" />
<Compile Include="ObjectExtensionsTests.cs" />
@@ -11,7 +11,7 @@ namespace Umbraco.Web
/// 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 DefaultDynamicDocumentDataSource : IDynamicDocumentDataSource
internal class DefaultDynamicPublishedContentDataSource : IDynamicPublishedContentDataSource
{
public Guid GetDataType(string docTypeAlias, string propertyAlias)
{
@@ -6,9 +6,9 @@ namespace Umbraco.Web
/// <summary>
/// DynamicPublishedContent extension methods for searching using Examine
/// </summary>
public static class DynamicDocumentSearchExtensions
public static class DynamicPublishedContentSearchExtensions
{
public static DynamicDocumentList Search(this DynamicPublishedContent d, string term, bool useWildCards = true, string searchProvider = null)
public static DynamicPublishedContentList Search(this DynamicPublishedContent d, string term, bool useWildCards = true, string searchProvider = null)
{
var searcher = Examine.ExamineManager.Instance.DefaultSearchProvider;
if (!string.IsNullOrEmpty(searchProvider))
@@ -24,12 +24,12 @@ namespace Umbraco.Web
return d.Search(crit, searcher);
}
public static DynamicDocumentList SearchDescendants(this DynamicPublishedContent d, string term, bool useWildCards = true, string searchProvider = null)
public static DynamicPublishedContentList SearchDescendants(this DynamicPublishedContent d, string term, bool useWildCards = true, string searchProvider = null)
{
return d.Search(term, useWildCards, searchProvider);
}
public static DynamicDocumentList SearchChildren(this DynamicPublishedContent d, string term, bool useWildCards = true, string searchProvider = null)
public static DynamicPublishedContentList SearchChildren(this DynamicPublishedContent d, string term, bool useWildCards = true, string searchProvider = null)
{
var searcher = Examine.ExamineManager.Instance.DefaultSearchProvider;
if (!string.IsNullOrEmpty(searchProvider))
@@ -45,7 +45,7 @@ namespace Umbraco.Web
return d.Search(crit, searcher);
}
public static DynamicDocumentList Search(this DynamicPublishedContent d, Examine.SearchCriteria.ISearchCriteria criteria, Examine.Providers.BaseSearchProvider searchProvider = null)
public static DynamicPublishedContentList Search(this DynamicPublishedContent d, Examine.SearchCriteria.ISearchCriteria criteria, Examine.Providers.BaseSearchProvider searchProvider = null)
{
var s = Examine.ExamineManager.Instance.DefaultSearchProvider;
if (searchProvider != null)
+2 -2
View File
@@ -12,7 +12,7 @@ namespace Umbraco.Web
/// </summary>
internal static class ExamineExtensions
{
internal static DynamicDocumentList ConvertSearchResultToDynamicDocument(
internal static DynamicPublishedContentList ConvertSearchResultToDynamicDocument(
this IEnumerable<SearchResult> results,
IPublishedStore store)
{
@@ -20,7 +20,7 @@ namespace Umbraco.Web
// however thsi is currently not the case:
// http://examine.codeplex.com/workitem/10350
var list = new DynamicDocumentList();
var list = new DynamicPublishedContentList();
var xd = new XmlDocument();
foreach (var result in results.OrderByDescending(x => x.Score))
@@ -16,7 +16,7 @@ namespace Umbraco.Web
/// These methods exist in the web project as we need access to web based classes like NiceUrl provider
/// which is why they cannot exist in the Core project.
/// </remarks>
public static class DocumentExtensions
public static class PublishedContentExtensions
{
/// <summary>
+3 -3
View File
@@ -250,12 +250,12 @@
<Compile Include="BaseRest\RestExtensionAttribute.cs" />
<Compile Include="BaseRest\RestExtensionMethodAttribute.cs" />
<Compile Include="BaseRest\RestExtensionMethodInfo.cs" />
<Compile Include="DefaultDynamicDocumentDataSource.cs" />
<Compile Include="DefaultDynamicPublishedContentDataSource.cs" />
<Compile Include="DefaultPublishedMediaStore.cs" />
<Compile Include="Dictionary\UmbracoCultureDictionary.cs" />
<Compile Include="Dictionary\UmbracoCultureDictionaryFactory.cs" />
<Compile Include="DocumentExtensions.cs" />
<Compile Include="DynamicDocumentSearchExtensions.cs" />
<Compile Include="PublishedContentExtensions.cs" />
<Compile Include="DynamicPublishedContentSearchExtensions.cs" />
<Compile Include="ExamineExtensions.cs" />
<Compile Include="FormlessPage.cs">
<SubType>ASPXCodeBehind</SubType>
+2 -2
View File
@@ -463,7 +463,7 @@ namespace Umbraco.Web
var nodes = ids.Select(eachId => DocumentById(eachId, store))
.Where(x => !TypeHelper.IsTypeAssignableFrom<DynamicNull>(x))
.Cast<DynamicPublishedContent>();
return new DynamicDocumentList(nodes);
return new DynamicPublishedContentList(nodes);
}
private dynamic DocumentByIds(IPublishedStore store, params string[] ids)
@@ -471,7 +471,7 @@ namespace Umbraco.Web
var nodes = ids.Select(eachId => DocumentById(eachId, store))
.Where(x => !TypeHelper.IsTypeAssignableFrom<DynamicNull>(x))
.Cast<DynamicPublishedContent>();
return new DynamicDocumentList(nodes);
return new DynamicPublishedContentList(nodes);
}
#endregion
+1 -1
View File
@@ -228,7 +228,7 @@ namespace Umbraco.Web
//This exists only because the new business logic classes aren't created yet and we want Dynamics in the Core project,
//see the note in the DynamicNodeDataSourceResolver.cs class
DynamicDocumentDataSourceResolver.Current = new DynamicDocumentDataSourceResolver(new DefaultDynamicDocumentDataSource());
DynamicPublishedContentDataSourceResolver.Current = new DynamicPublishedContentDataSourceResolver(new DefaultDynamicPublishedContentDataSource());
}
}
@@ -544,7 +544,7 @@ namespace umbraco.MacroEngines
//contextAlias is the node which the property data was returned from
//Guid dataType = ContentType.GetDataType(data.ContextAlias, data.Alias);
//SD: replaced with our temporary resolver so that we can unit test this properly, this is what DynamicPublishedContent uses until we create our new data access layer.
var dataType = DynamicDocumentDataSourceResolver.Current.DataSource.GetDataType(data.ContextAlias, data.Alias);
var dataType = DynamicPublishedContentDataSourceResolver.Current.DataSource.GetDataType(data.ContextAlias, data.Alias);
var staticMapping = UmbracoSettings.RazorDataTypeModelStaticMapping.FirstOrDefault(mapping =>
{
@@ -12,7 +12,7 @@ namespace umbraco.MacroEngines.Library
/// <summary>
/// Extension methods for converting DynamicPublishedContent to INode
/// </summary>
internal static class DynamicDocumentExtensions
internal static class DynamicPublishedContentExtensions
{
internal static IProperty ConvertToNodeProperty(this IDocumentProperty prop)
@@ -144,7 +144,7 @@ namespace umbraco.MacroEngines.Library
public dynamic Search(string term, bool useWildCards = true, string searchProvider = null)
{
//wraps the functionality in UmbracoHelper but still returns the legacy DynamicNodeList
var nodes = ((DynamicDocumentList)_umbracoHelper.Search(term, useWildCards, searchProvider))
var nodes = ((DynamicPublishedContentList)_umbracoHelper.Search(term, useWildCards, searchProvider))
.Select(x => x.ConvertToNode());
return new DynamicNodeList(nodes);
}
@@ -152,7 +152,7 @@ namespace umbraco.MacroEngines.Library
public dynamic Search(Examine.SearchCriteria.ISearchCriteria criteria, Examine.Providers.BaseSearchProvider searchProvider = null)
{
//wraps the functionality in UmbracoHelper but still returns the legacy DynamicNodeList
var nodes = ((DynamicDocumentList) _umbracoHelper.Search(criteria, searchProvider))
var nodes = ((DynamicPublishedContentList) _umbracoHelper.Search(criteria, searchProvider))
.Select(x => x.ConvertToNode());
return new DynamicNodeList(nodes);
}
@@ -86,7 +86,7 @@
<Compile Include="RazorDynamicNode\DynamicBackingItem.cs" />
<Compile Include="RazorDynamicNode\DynamicBackingItemType.cs" />
<Compile Include="RazorDynamicNode\DynamicClass.cs" />
<Compile Include="RazorDynamicNode\DynamicDocumentExtensions.cs" />
<Compile Include="RazorDynamicNode\DynamicPublishedContentExtensions.cs" />
<Compile Include="RazorDynamicNode\DynamicExpression.cs" />
<Compile Include="RazorDynamicNode\DynamicGrouping.cs" />
<Compile Include="RazorDynamicNode\DynamicMedia.cs">