diff --git a/src/Umbraco.Core/DataTableExtensions.cs b/src/Umbraco.Core/DataTableExtensions.cs index 8c29d948ac..bf6967da4b 100644 --- a/src/Umbraco.Core/DataTableExtensions.cs +++ b/src/Umbraco.Core/DataTableExtensions.cs @@ -28,7 +28,7 @@ namespace Umbraco.Core /// /// /// This has been migrated from the Node class and uses proper locking now. It is now used by the Node class and the - /// DynamicDocument extensions for legacy reasons. + /// DynamicPublishedContent extensions for legacy reasons. /// public static DataTable GenerateDataTable( string tableAlias, diff --git a/src/Umbraco.Core/DocumentExtensions.cs b/src/Umbraco.Core/DocumentExtensions.cs index 4212dc49a1..ae6b8febe5 100644 --- a/src/Umbraco.Core/DocumentExtensions.cs +++ b/src/Umbraco.Core/DocumentExtensions.cs @@ -11,9 +11,9 @@ namespace Umbraco.Core public static class DocumentExtensions { - public static dynamic AsDynamic(this IDocument doc) + public static dynamic AsDynamic(this IPublishedContent doc) { - var dd = new DynamicDocument(doc); + var dd = new DynamicPublishedContent(doc); return dd.AsDynamic(); } @@ -25,12 +25,12 @@ namespace Umbraco.Core /// /// /// - public static T GetPropertyValue(this IDocument prop, string alias) + public static T GetPropertyValue(this IPublishedContent prop, string alias) { return prop.GetPropertyValue(alias, default(T)); } - public static T GetPropertyValue(this IDocument prop, string alias, T ifCannotConvert) + public static T GetPropertyValue(this IPublishedContent prop, string alias, T ifCannotConvert) { var p = prop.GetProperty(alias); if (p == null) diff --git a/src/Umbraco.Core/Dynamics/DynamicDocumentIdEqualityComparer.cs b/src/Umbraco.Core/Dynamics/DynamicDocumentIdEqualityComparer.cs index 8ad63cea5d..62243570a1 100644 --- a/src/Umbraco.Core/Dynamics/DynamicDocumentIdEqualityComparer.cs +++ b/src/Umbraco.Core/Dynamics/DynamicDocumentIdEqualityComparer.cs @@ -3,10 +3,10 @@ using System.Collections.Generic; namespace Umbraco.Core.Dynamics { - internal class DynamicDocumentIdEqualityComparer : EqualityComparer + internal class DynamicDocumentIdEqualityComparer : EqualityComparer { - public override bool Equals(DynamicDocument x, DynamicDocument y) + public override bool Equals(DynamicPublishedContent x, DynamicPublishedContent y) { //Check whether the compared objects reference the same data. if (Object.ReferenceEquals(x, y)) return true; @@ -20,7 +20,7 @@ namespace Umbraco.Core.Dynamics } - public override int GetHashCode(DynamicDocument obj) + public override int GetHashCode(DynamicPublishedContent obj) { if (Object.ReferenceEquals(obj, null)) return 0; diff --git a/src/Umbraco.Core/Dynamics/DynamicDocumentList.cs b/src/Umbraco.Core/Dynamics/DynamicDocumentList.cs index 3d95c04beb..0a491a1a16 100644 --- a/src/Umbraco.Core/Dynamics/DynamicDocumentList.cs +++ b/src/Umbraco.Core/Dynamics/DynamicDocumentList.cs @@ -9,24 +9,24 @@ using System.Reflection; namespace Umbraco.Core.Dynamics { - public class DynamicDocumentList : DynamicObject, IEnumerable + public class DynamicDocumentList : DynamicObject, IEnumerable { - internal List Items { get; set; } + internal List Items { get; set; } public DynamicDocumentList() { - Items = new List(); + Items = new List(); } - public DynamicDocumentList(IEnumerable items) + public DynamicDocumentList(IEnumerable items) { - List list = items.ToList(); + List list = items.ToList(); list.ForEach(node => node.OwnerList = this); Items = list; } - public DynamicDocumentList(IEnumerable items) + public DynamicDocumentList(IEnumerable items) { - List list = items.Select(x => new DynamicDocument(x)).ToList(); + List list = items.Select(x => new DynamicPublishedContent(x)).ToList(); list.ForEach(node => node.OwnerList = this); Items = list; } @@ -61,14 +61,14 @@ 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(predicate, values).ToList()); + result = new DynamicDocumentList(this.Where(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(args.First().ToString()).ToList()); + result = new DynamicDocumentList(this.OrderBy(args.First().ToString()).ToList()); return true; } if (name == "Take") @@ -86,7 +86,7 @@ namespace Umbraco.Core.Dynamics int groupSize = 0; if (int.TryParse(args.First().ToString(), out groupSize)) { - result = this.InGroupsOf(groupSize); + result = this.InGroupsOf(groupSize); return true; } result = new DynamicNull(); @@ -97,7 +97,7 @@ namespace Umbraco.Core.Dynamics int groupCount = 0; if (int.TryParse(args.First().ToString(), out groupCount)) { - result = this.GroupedInto(groupCount); + result = this.GroupedInto(groupCount); return true; } result = new DynamicNull(); @@ -105,7 +105,7 @@ namespace Umbraco.Core.Dynamics } if (name == "GroupBy") { - result = this.GroupBy(args.First().ToString()); + result = this.GroupBy(args.First().ToString()); return true; } if (name == "Average" || name == "Min" || name == "Max" || name == "Sum") @@ -115,9 +115,9 @@ namespace Umbraco.Core.Dynamics } if (name == "Union") { - if ((args.First() as IEnumerable) != null) + if ((args.First() as IEnumerable) != null) { - result = new DynamicDocumentList(this.Items.Union(args.First() as IEnumerable)); + result = new DynamicDocumentList(this.Items.Union(args.First() as IEnumerable)); return true; } if ((args.First() as DynamicDocumentList) != null) @@ -128,9 +128,9 @@ namespace Umbraco.Core.Dynamics } if (name == "Except") { - if ((args.First() as IEnumerable) != null) + if ((args.First() as IEnumerable) != null) { - result = new DynamicDocumentList(this.Items.Except(args.First() as IEnumerable, new DynamicDocumentIdEqualityComparer())); + result = new DynamicDocumentList(this.Items.Except(args.First() as IEnumerable, new DynamicDocumentIdEqualityComparer())); return true; } if ((args.First() as DynamicDocumentList) != null) @@ -141,9 +141,9 @@ namespace Umbraco.Core.Dynamics } if (name == "Intersect") { - if ((args.First() as IEnumerable) != null) + if ((args.First() as IEnumerable) != null) { - result = new DynamicDocumentList(this.Items.Intersect(args.First() as IEnumerable, new DynamicDocumentIdEqualityComparer())); + result = new DynamicDocumentList(this.Items.Intersect(args.First() as IEnumerable, new DynamicDocumentIdEqualityComparer())); return true; } if ((args.First() as DynamicDocumentList) != null) @@ -202,7 +202,7 @@ namespace Umbraco.Core.Dynamics //We do this to enable error checking of Razor Syntax when a method e.g. ElementAt(2) is used. //When the Script is tested, there's no Children which means ElementAt(2) is invalid (IndexOutOfRange) //Instead, we are going to return an empty DynamicNode. - result = DynamicDocument.Empty(); + result = DynamicPublishedContent.Empty(); return true; } @@ -368,7 +368,7 @@ namespace Umbraco.Core.Dynamics var methodTypesToFind = new[] { - typeof(IEnumerable), + typeof(IEnumerable), typeof(DynamicDocumentList) }; @@ -406,17 +406,17 @@ namespace Umbraco.Core.Dynamics } if (result != null) { - if (result is IDocument) + if (result is IPublishedContent) { - result = new DynamicDocument((IDocument)result); + result = new DynamicPublishedContent((IPublishedContent)result); } - if (result is IEnumerable) + if (result is IEnumerable) { - result = new DynamicDocumentList((IEnumerable)result); + result = new DynamicDocumentList((IEnumerable)result); } - if (result is IEnumerable) + if (result is IEnumerable) { - result = new DynamicDocumentList((IEnumerable)result); + result = new DynamicDocumentList((IEnumerable)result); } } return result; @@ -441,9 +441,9 @@ namespace Umbraco.Core.Dynamics return new DynamicGrouping( this .Items - .Select((node, index) => new KeyValuePair(index, node)) + .Select((node, index) => new KeyValuePair(index, node)) .GroupBy(kv => (object)(kv.Key / groupSize)) - .Select(item => new Grouping() + .Select(item => new Grouping() { Key = item.Key, Elements = item.Select(inner => inner.Value) @@ -454,9 +454,9 @@ namespace Umbraco.Core.Dynamics return new DynamicGrouping( this .Items - .Select((node, index) => new KeyValuePair(index, node)) + .Select((node, index) => new KeyValuePair(index, node)) .GroupBy(kv => (object)(kv.Key / groupSize)) - .Select(item => new Grouping() + .Select(item => new Grouping() { Key = item.Key, Elements = item.Select(inner => inner.Value) @@ -469,17 +469,17 @@ namespace Umbraco.Core.Dynamics return Items.AsQueryable().Select(predicate, values); } - public void Add(DynamicDocument document) + public void Add(DynamicPublishedContent publishedContent) { - document.OwnerList = this; - this.Items.Add(document); + publishedContent.OwnerList = this; + this.Items.Add(publishedContent); } - public void Remove(DynamicDocument document) + public void Remove(DynamicPublishedContent publishedContent) { - if (this.Items.Contains(document)) + if (this.Items.Contains(publishedContent)) { - document.OwnerList = null; - this.Items.Remove(document); + publishedContent.OwnerList = null; + this.Items.Remove(publishedContent); } } public bool IsNull() @@ -491,7 +491,7 @@ namespace Umbraco.Core.Dynamics return true; } - public IEnumerator GetEnumerator() + public IEnumerator GetEnumerator() { return Items.GetEnumerator(); } diff --git a/src/Umbraco.Core/Dynamics/DynamicDocumentListOrdering.cs b/src/Umbraco.Core/Dynamics/DynamicDocumentListOrdering.cs index 3d408db28b..39d987f509 100644 --- a/src/Umbraco.Core/Dynamics/DynamicDocumentListOrdering.cs +++ b/src/Umbraco.Core/Dynamics/DynamicDocumentListOrdering.cs @@ -8,12 +8,12 @@ namespace Umbraco.Core.Dynamics internal static class DynamicDocumentListOrdering { - private static TOut Reduce(Func func, DynamicDocument document) + private static TOut Reduce(Func func, DynamicPublishedContent publishedContent) { - var value = func(document); - while (value is Func) + var value = func(publishedContent); + while (value is Func) { - value = (value as Func)(document); + value = (value as Func)(publishedContent); } //when you're sorting a list of properties //and one of those properties doesn't exist, it will come back as DynamicNull @@ -37,209 +37,209 @@ namespace Umbraco.Core.Dynamics } return (TOut)value; } - public static IOrderedQueryable OrderBy(object source, object key) + public static IOrderedQueryable OrderBy(object source, object key) { - IEnumerable typedSource = source as IEnumerable; + IEnumerable typedSource = source as IEnumerable; LambdaExpression lambda = key as LambdaExpression; //if the lambda we have returns an actual property, not a dynamic one, //then the TOut of the func will be the actual type, not object //Func func = (Func)lambda.Compile(); var func = lambda.Compile(); var TOut = func.GetType().GetGenericArguments()[1]; - IOrderedQueryable result = null; - if (TOut == typeof(Func)) + IOrderedQueryable result = null; + if (TOut == typeof(Func)) { - result = (IOrderedQueryable)typedSource - .OrderBy(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .OrderBy(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(object)) { - result = (IOrderedQueryable)typedSource - .OrderBy(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .OrderBy(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(bool)) { - result = (IOrderedQueryable)typedSource - .OrderBy(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .OrderBy(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(decimal)) { - result = (IOrderedQueryable)typedSource - .OrderBy(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .OrderBy(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(int)) { - result = (IOrderedQueryable)typedSource - .OrderBy(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .OrderBy(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(string)) { - result = (IOrderedQueryable)typedSource - .OrderBy(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .OrderBy(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(DateTime)) { - result = (IOrderedQueryable)typedSource - .OrderBy(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .OrderBy(x => Reduce(func as Func, x)) .AsQueryable(); } return result; } - public static IOrderedQueryable ThenBy(object source, object key) + public static IOrderedQueryable ThenBy(object source, object key) { - IOrderedQueryable typedSource = source as IOrderedQueryable; + IOrderedQueryable typedSource = source as IOrderedQueryable; LambdaExpression lambda = key as LambdaExpression; var func = lambda.Compile(); var TOut = func.GetType().GetGenericArguments()[1]; - IOrderedQueryable result = null; - if (TOut == typeof(Func)) + IOrderedQueryable result = null; + if (TOut == typeof(Func)) { - result = (IOrderedQueryable)typedSource - .ThenBy(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .ThenBy(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(object)) { - result = (IOrderedQueryable)typedSource - .ThenBy(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .ThenBy(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(bool)) { - result = (IOrderedQueryable)typedSource - .ThenBy(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .ThenBy(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(decimal)) { - result = (IOrderedQueryable)typedSource - .ThenBy(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .ThenBy(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(int)) { - result = (IOrderedQueryable)typedSource - .ThenBy(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .ThenBy(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(string)) { - result = (IOrderedQueryable)typedSource - .ThenBy(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .ThenBy(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(DateTime)) { - result = (IOrderedQueryable)typedSource - .ThenBy(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .ThenBy(x => Reduce(func as Func, x)) .AsQueryable(); } return result; } - public static IOrderedQueryable OrderByDescending(object source, object key) + public static IOrderedQueryable OrderByDescending(object source, object key) { - IEnumerable typedSource = source as IEnumerable; + IEnumerable typedSource = source as IEnumerable; LambdaExpression lambda = key as LambdaExpression; var func = lambda.Compile(); var TOut = func.GetType().GetGenericArguments()[1]; - IOrderedQueryable result = null; - if (TOut == typeof(Func)) + IOrderedQueryable result = null; + if (TOut == typeof(Func)) { - result = (IOrderedQueryable)typedSource - .OrderByDescending(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .OrderByDescending(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(object)) { - result = (IOrderedQueryable)typedSource - .OrderByDescending(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .OrderByDescending(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(bool)) { - result = (IOrderedQueryable)typedSource - .OrderByDescending(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .OrderByDescending(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(decimal)) { - result = (IOrderedQueryable)typedSource - .OrderByDescending(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .OrderByDescending(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(int)) { - result = (IOrderedQueryable)typedSource - .OrderByDescending(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .OrderByDescending(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(string)) { - result = (IOrderedQueryable)typedSource - .OrderByDescending(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .OrderByDescending(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(DateTime)) { - result = (IOrderedQueryable)typedSource - .OrderByDescending(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .OrderByDescending(x => Reduce(func as Func, x)) .AsQueryable(); } return result; } - public static IOrderedQueryable ThenByDescending(object source, object key) + public static IOrderedQueryable ThenByDescending(object source, object key) { - IOrderedQueryable typedSource = source as IOrderedQueryable; + IOrderedQueryable typedSource = source as IOrderedQueryable; LambdaExpression lambda = key as LambdaExpression; var func = lambda.Compile(); var TOut = func.GetType().GetGenericArguments()[1]; - IOrderedQueryable result = null; - if (TOut == typeof(Func)) + IOrderedQueryable result = null; + if (TOut == typeof(Func)) { - result = (IOrderedQueryable)typedSource - .ThenByDescending(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .ThenByDescending(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(object)) { - result = (IOrderedQueryable)typedSource - .ThenByDescending(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .ThenByDescending(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(bool)) { - result = (IOrderedQueryable)typedSource - .ThenByDescending(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .ThenByDescending(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(decimal)) { - result = (IOrderedQueryable)typedSource - .ThenByDescending(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .ThenByDescending(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(int)) { - result = (IOrderedQueryable)typedSource - .ThenByDescending(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .ThenByDescending(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(string)) { - result = (IOrderedQueryable)typedSource - .ThenByDescending(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .ThenByDescending(x => Reduce(func as Func, x)) .AsQueryable(); } if (TOut == typeof(DateTime)) { - result = (IOrderedQueryable)typedSource - .ThenByDescending(x => Reduce(func as Func, x)) + result = (IOrderedQueryable)typedSource + .ThenByDescending(x => Reduce(func as Func, x)) .AsQueryable(); } return result; diff --git a/src/Umbraco.Core/Dynamics/DynamicDocumentWalker.cs b/src/Umbraco.Core/Dynamics/DynamicDocumentWalker.cs index 9f52378dce..0fa83c4c63 100644 --- a/src/Umbraco.Core/Dynamics/DynamicDocumentWalker.cs +++ b/src/Umbraco.Core/Dynamics/DynamicDocumentWalker.cs @@ -6,11 +6,11 @@ namespace Umbraco.Core.Dynamics { internal static class DynamicDocumentWalker { - public static DynamicDocument Up(this DynamicDocument context) + public static DynamicPublishedContent Up(this DynamicPublishedContent context) { return context.Up(0); } - public static DynamicDocument Up(this DynamicDocument context, int number) + public static DynamicPublishedContent Up(this DynamicPublishedContent context, int number) { if (number == 0) { @@ -22,7 +22,7 @@ namespace Umbraco.Core.Dynamics return context; } } - public static DynamicDocument Up(this DynamicDocument context, string nodeTypeAlias) + public static DynamicPublishedContent Up(this DynamicPublishedContent context, string nodeTypeAlias) { if (string.IsNullOrEmpty(nodeTypeAlias)) { @@ -35,11 +35,11 @@ namespace Umbraco.Core.Dynamics } } - public static DynamicDocument Down(this DynamicDocument context) + public static DynamicPublishedContent Down(this DynamicPublishedContent context) { return context.Down(0); } - public static DynamicDocument Down(this DynamicDocument context, int number) + public static DynamicPublishedContent Down(this DynamicPublishedContent context, int number) { var children = new DynamicDocumentList(context.Children); if (number == 0) @@ -48,7 +48,7 @@ namespace Umbraco.Core.Dynamics } else { - DynamicDocument working = context; + DynamicPublishedContent working = context; while (number-- >= 0) { working = children.Items.First(); @@ -57,7 +57,7 @@ namespace Umbraco.Core.Dynamics return working; } } - public static DynamicDocument Down(this DynamicDocument context, string nodeTypeAlias) + public static DynamicPublishedContent Down(this DynamicPublishedContent context, string nodeTypeAlias) { if (string.IsNullOrEmpty(nodeTypeAlias)) @@ -70,11 +70,11 @@ namespace Umbraco.Core.Dynamics return context.Descendants(nodeTypeAlias).Items.FirstOrDefault(); } } - public static DynamicDocument Next(this DynamicDocument context) + public static DynamicPublishedContent Next(this DynamicPublishedContent context) { return context.Next(0); } - public static DynamicDocument Next(this DynamicDocument context, int number) + public static DynamicPublishedContent Next(this DynamicPublishedContent context, int number) { if (context.OwnerList == null && context.Parent != null) { @@ -100,7 +100,7 @@ namespace Umbraco.Core.Dynamics throw new ArgumentNullException(string.Format("Node {0} has been orphaned and doesn't belong to a DynamicNodeList", context.Id)); } } - public static DynamicDocument Sibling(this DynamicDocument context, int number) + public static DynamicPublishedContent Sibling(this DynamicPublishedContent context, int number) { if (context.OwnerList == null && context.Parent != null) { @@ -126,7 +126,7 @@ namespace Umbraco.Core.Dynamics throw new ArgumentNullException(string.Format("Node {0} has been orphaned and doesn't belong to a DynamicNodeList", context.Id)); } } - public static DynamicDocument Sibling(this DynamicDocument context, string nodeTypeAlias) + public static DynamicPublishedContent Sibling(this DynamicPublishedContent context, string nodeTypeAlias) { if (context.OwnerList == null && context.Parent != null) { @@ -166,7 +166,7 @@ namespace Umbraco.Core.Dynamics throw new ArgumentNullException(string.Format("Node {0} has been orphaned and doesn't belong to a DynamicNodeList", context.Id)); } } - public static DynamicDocument Next(this DynamicDocument context, string nodeTypeAlias) + public static DynamicPublishedContent Next(this DynamicPublishedContent context, string nodeTypeAlias) { if (context.OwnerList == null && context.Parent != null) { @@ -197,11 +197,11 @@ namespace Umbraco.Core.Dynamics throw new ArgumentNullException(string.Format("Node {0} has been orphaned and doesn't belong to a DynamicNodeList", context.Id)); } } - public static DynamicDocument Previous(this DynamicDocument context) + public static DynamicPublishedContent Previous(this DynamicPublishedContent context) { return context.Previous(0); } - public static DynamicDocument Previous(this DynamicDocument context, int number) + public static DynamicPublishedContent Previous(this DynamicPublishedContent context, int number) { if (context.OwnerList == null && context.Parent != null) { @@ -211,7 +211,7 @@ namespace Umbraco.Core.Dynamics } if (context.OwnerList != null) { - List container = context.OwnerList.Items.ToList(); + List container = context.OwnerList.Items.ToList(); int currentIndex = container.FindIndex(n => n.Id == context.Id); if (currentIndex != -1) { @@ -227,7 +227,7 @@ namespace Umbraco.Core.Dynamics throw new ArgumentNullException(string.Format("Node {0} has been orphaned and doesn't belong to a DynamicNodeList", context.Id)); } } - public static DynamicDocument Previous(this DynamicDocument context, string nodeTypeAlias) + public static DynamicPublishedContent Previous(this DynamicPublishedContent context, string nodeTypeAlias) { if (context.OwnerList == null && context.Parent != null) { @@ -237,7 +237,7 @@ namespace Umbraco.Core.Dynamics } if (context.OwnerList != null) { - List container = context.OwnerList.Items.ToList(); + List container = context.OwnerList.Items.ToList(); int currentIndex = container.FindIndex(n => n.Id == context.Id); if (currentIndex != -1) { diff --git a/src/Umbraco.Core/Dynamics/DynamicGrouping.cs b/src/Umbraco.Core/Dynamics/DynamicGrouping.cs index d843fa52b1..6a0dca0609 100644 --- a/src/Umbraco.Core/Dynamics/DynamicGrouping.cs +++ b/src/Umbraco.Core/Dynamics/DynamicGrouping.cs @@ -6,7 +6,7 @@ namespace Umbraco.Core.Dynamics { public class DynamicGrouping : IEnumerable { - internal IEnumerable> Inner; + internal IEnumerable> Inner; public DynamicGrouping OrderBy(string expression) { @@ -21,7 +21,7 @@ namespace Umbraco.Core.Dynamics .Select(node => { string predicate = groupBy; - var internalList = new DynamicDocumentList(new DynamicDocument[] { node }); + var internalList = new DynamicDocumentList(new DynamicPublishedContent[] { node }); var query = (IQueryable)internalList.Select(predicate, new object[] { }); var key = query.FirstOrDefault(); return new @@ -32,13 +32,13 @@ namespace Umbraco.Core.Dynamics }) .Where(item => item.Key != null) .GroupBy(item => item.Key) - .Select(item => new Grouping() + .Select(item => new Grouping() { Key = item.Key, Elements = item.Select(inner => inner.Node) }); } - internal DynamicGrouping(IEnumerable> source) + internal DynamicGrouping(IEnumerable> source) { this.Inner = source; } diff --git a/src/Umbraco.Core/Dynamics/DynamicDocument.cs b/src/Umbraco.Core/Dynamics/DynamicPublishedContent.cs similarity index 77% rename from src/Umbraco.Core/Dynamics/DynamicDocument.cs rename to src/Umbraco.Core/Dynamics/DynamicPublishedContent.cs index 39235b6150..efc97dba7a 100644 --- a/src/Umbraco.Core/Dynamics/DynamicDocument.cs +++ b/src/Umbraco.Core/Dynamics/DynamicPublishedContent.cs @@ -17,9 +17,9 @@ namespace Umbraco.Core.Dynamics /// /// The dynamic model for views /// - public class DynamicDocument : DynamicObject, IDocument + public class DynamicPublishedContent : DynamicObject, IPublishedContent { - private readonly IDocument _document; + private readonly IPublishedContent _publishedContent; private DynamicDocumentList _cachedChildren; private readonly ConcurrentDictionary _cachedMemberOutput = new ConcurrentDictionary(); @@ -27,22 +27,22 @@ namespace Umbraco.Core.Dynamics #region Constructors - public DynamicDocument(IDocument node) + public DynamicPublishedContent(IPublishedContent node) { if (node == null) throw new ArgumentNullException("node"); - _document = node; + _publishedContent = node; } /// - /// Returns an empty/blank DynamicDocument, this is used for special case scenarios + /// Returns an empty/blank DynamicPublishedContent, this is used for special case scenarios /// /// - internal static DynamicDocument Empty() + internal static DynamicPublishedContent Empty() { - return new DynamicDocument(); + return new DynamicPublishedContent(); } - private DynamicDocument() + private DynamicPublishedContent() { } @@ -54,60 +54,60 @@ namespace Umbraco.Core.Dynamics } #region Traversal - public DynamicDocument Up() + public DynamicPublishedContent Up() { return DynamicDocumentWalker.Up(this); } - public DynamicDocument Up(int number) + public DynamicPublishedContent Up(int number) { return DynamicDocumentWalker.Up(this, number); } - public DynamicDocument Up(string nodeTypeAlias) + public DynamicPublishedContent Up(string nodeTypeAlias) { return DynamicDocumentWalker.Up(this, nodeTypeAlias); } - public DynamicDocument Down() + public DynamicPublishedContent Down() { return DynamicDocumentWalker.Down(this); } - public DynamicDocument Down(int number) + public DynamicPublishedContent Down(int number) { return DynamicDocumentWalker.Down(this, number); } - public DynamicDocument Down(string nodeTypeAlias) + public DynamicPublishedContent Down(string nodeTypeAlias) { return DynamicDocumentWalker.Down(this, nodeTypeAlias); } - public DynamicDocument Next() + public DynamicPublishedContent Next() { return DynamicDocumentWalker.Next(this); } - public DynamicDocument Next(int number) + public DynamicPublishedContent Next(int number) { return DynamicDocumentWalker.Next(this, number); } - public DynamicDocument Next(string nodeTypeAlias) + public DynamicPublishedContent Next(string nodeTypeAlias) { return DynamicDocumentWalker.Next(this, nodeTypeAlias); } - public DynamicDocument Previous() + public DynamicPublishedContent Previous() { return DynamicDocumentWalker.Previous(this); } - public DynamicDocument Previous(int number) + public DynamicPublishedContent Previous(int number) { return DynamicDocumentWalker.Previous(this, number); } - public DynamicDocument Previous(string nodeTypeAlias) + public DynamicPublishedContent Previous(string nodeTypeAlias) { return DynamicDocumentWalker.Previous(this, nodeTypeAlias); } - public DynamicDocument Sibling(int number) + public DynamicPublishedContent Sibling(int number) { return DynamicDocumentWalker.Sibling(this, number); } - public DynamicDocument Sibling(string nodeTypeAlias) + public DynamicPublishedContent Sibling(string nodeTypeAlias) { return DynamicDocumentWalker.Sibling(this, nodeTypeAlias); } @@ -115,7 +115,7 @@ namespace Umbraco.Core.Dynamics public bool HasProperty(string name) { - if (_document != null) + if (_publishedContent != null) { try { @@ -145,7 +145,7 @@ namespace Umbraco.Core.Dynamics try { //Property? - result = typeof(DynamicDocument).InvokeMember(binder.Name, + result = typeof(DynamicPublishedContent).InvokeMember(binder.Name, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty, @@ -159,7 +159,7 @@ namespace Umbraco.Core.Dynamics try { //Static or Instance Method? - result = typeof(DynamicDocument).InvokeMember(binder.Name, + result = typeof(DynamicPublishedContent).InvokeMember(binder.Name, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | @@ -208,7 +208,7 @@ namespace Umbraco.Core.Dynamics var methodTypesToFind = new[] { - typeof(DynamicDocument) + typeof(DynamicPublishedContent) }; //find known extension methods that match the first type in the list @@ -231,17 +231,17 @@ namespace Umbraco.Core.Dynamics } if (result != null) { - if (result is IDocument) + if (result is IPublishedContent) { - result = new DynamicDocument((IDocument)result); + result = new DynamicPublishedContent((IPublishedContent)result); } - if (result is IEnumerable) + if (result is IEnumerable) { - result = new DynamicDocumentList((IEnumerable)result); + result = new DynamicDocumentList((IEnumerable)result); } - if (result is IEnumerable) + if (result is IEnumerable) { - result = new DynamicDocumentList((IEnumerable)result); + result = new DynamicDocumentList((IEnumerable)result); } } return result; @@ -283,13 +283,13 @@ namespace Umbraco.Core.Dynamics protected virtual Attempt TryGetChildrenByAlias(GetMemberBinder binder) { - var filteredTypeChildren = _document.Children + var filteredTypeChildren = _publishedContent.Children .Where(x => x.DocumentTypeAlias.InvariantEquals(binder.Name) || x.DocumentTypeAlias.MakePluralName().InvariantEquals(binder.Name)) .ToArray(); if (filteredTypeChildren.Any()) { return new Attempt(true, - new DynamicDocumentList(filteredTypeChildren.Select(x => new DynamicDocument(x)))); + new DynamicDocumentList(filteredTypeChildren.Select(x => new DynamicPublishedContent(x)))); } return Attempt.False; } @@ -336,7 +336,7 @@ namespace Umbraco.Core.Dynamics var result = userProperty.Value; - if (_document.DocumentTypeAlias == null && userProperty.Alias == null) + if (_publishedContent.DocumentTypeAlias == null && userProperty.Alias == null) { throw new InvalidOperationException("No node alias or property alias available. Unable to look up the datatype of the property you are trying to fetch."); } @@ -429,7 +429,7 @@ namespace Umbraco.Core.Dynamics /// private PropertyResult GetReflectedProperty(string alias) { - return GetPropertyInternal(alias, _document, false); + return GetPropertyInternal(alias, _publishedContent, false); } /// @@ -442,21 +442,21 @@ namespace Umbraco.Core.Dynamics { if (!recursive) { - return GetPropertyInternal(alias, _document); + return GetPropertyInternal(alias, _publishedContent); } var context = this; - var prop = GetPropertyInternal(alias, _document); + var prop = GetPropertyInternal(alias, _publishedContent); while (prop == null || !prop.HasValue()) { context = context.Parent; if (context == null) break; - prop = context.GetPropertyInternal(alias, context._document); + prop = context.GetPropertyInternal(alias, context._publishedContent); } return prop; } - private PropertyResult GetPropertyInternal(string alias, IDocument content, bool checkUserProperty = true) + private PropertyResult GetPropertyInternal(string alias, IPublishedContent content, bool checkUserProperty = true) { if (alias.IsNullOrWhiteSpace()) throw new ArgumentNullException("alias"); if (content == null) throw new ArgumentNullException("content"); @@ -667,26 +667,26 @@ namespace Umbraco.Core.Dynamics //} #region Ancestors, Descendants and Parent - public DynamicDocument AncestorOrSelf() + public DynamicPublishedContent AncestorOrSelf() { //TODO: Why is this query like this?? return AncestorOrSelf(node => node.Level == 1); } - public DynamicDocument AncestorOrSelf(int level) + public DynamicPublishedContent AncestorOrSelf(int level) { return AncestorOrSelf(node => node.Level == level); } - public DynamicDocument AncestorOrSelf(string nodeTypeAlias) + public DynamicPublishedContent AncestorOrSelf(string nodeTypeAlias) { return AncestorOrSelf(node => node.DocumentTypeAlias == nodeTypeAlias); } - public DynamicDocument AncestorOrSelf(Func func) + public DynamicPublishedContent AncestorOrSelf(Func func) { var node = this; while (node != null) { if (func(node)) return node; - DynamicDocument parent = node.Parent; + DynamicPublishedContent parent = node.Parent; if (parent != null) { if (this != parent) @@ -705,15 +705,15 @@ namespace Umbraco.Core.Dynamics } return node; } - public DynamicDocumentList AncestorsOrSelf(Func func) + public DynamicDocumentList AncestorsOrSelf(Func func) { - var ancestorList = new List(); + var ancestorList = new List(); var node = this; ancestorList.Add(node); while (node != null) { if (node.Level == 1) break; - DynamicDocument parent = node.Parent; + DynamicPublishedContent parent = node.Parent; if (parent != null) { if (this != parent) @@ -761,10 +761,10 @@ namespace Umbraco.Core.Dynamics { return Descendants(n => true); } - internal DynamicDocumentList Descendants(Func func) + internal DynamicDocumentList Descendants(Func func) { - var flattenedNodes = this._document.Children.Map(func, (IDocument n) => n.Children); - return new DynamicDocumentList(flattenedNodes.ToList().ConvertAll(dynamicBackingItem => new DynamicDocument(dynamicBackingItem))); + var flattenedNodes = this._publishedContent.Children.Map(func, (IPublishedContent n) => n.Children); + return new DynamicDocumentList(flattenedNodes.ToList().ConvertAll(dynamicBackingItem => new DynamicPublishedContent(dynamicBackingItem))); } public DynamicDocumentList DescendantsOrSelf(int level) { @@ -778,19 +778,19 @@ namespace Umbraco.Core.Dynamics { return DescendantsOrSelf(p => true); } - internal DynamicDocumentList DescendantsOrSelf(Func func) + internal DynamicDocumentList DescendantsOrSelf(Func func) { - if (this._document != null) + if (this._publishedContent != null) { - var thisNode = new List(); - if (func(this._document)) + var thisNode = new List(); + if (func(this._publishedContent)) { - thisNode.Add(this._document); + thisNode.Add(this._publishedContent); } - var flattenedNodes = this._document.Children.Map(func, (IDocument n) => n.Children); - return new DynamicDocumentList(thisNode.Concat(flattenedNodes).ToList().ConvertAll(dynamicBackingItem => new DynamicDocument(dynamicBackingItem))); + 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 DynamicDocumentList(Enumerable.Empty()); + return new DynamicDocumentList(Enumerable.Empty()); } public DynamicDocumentList Ancestors(int level) { @@ -804,14 +804,14 @@ namespace Umbraco.Core.Dynamics { return Ancestors(n => true); } - public DynamicDocumentList Ancestors(Func func) + public DynamicDocumentList Ancestors(Func func) { - var ancestorList = new List(); + var ancestorList = new List(); var node = this; while (node != null) { if (node.Level == 1) break; - DynamicDocument parent = node.Parent; + DynamicPublishedContent parent = node.Parent; if (parent != null) { if (this != parent) @@ -835,15 +835,15 @@ namespace Umbraco.Core.Dynamics ancestorList.Reverse(); return new DynamicDocumentList(ancestorList); } - public DynamicDocument Parent + public DynamicPublishedContent Parent { get { - if (_document.Parent != null) + if (_publishedContent.Parent != null) { - return new DynamicDocument(_document.Parent); + return new DynamicPublishedContent(_publishedContent.Parent); } - if (_document != null && _document.Id == 0) + if (_publishedContent != null && _publishedContent.Id == 0) { return this; } @@ -854,17 +854,17 @@ namespace Umbraco.Core.Dynamics public int TemplateId { - get { return _document.TemplateId; } + get { return _publishedContent.TemplateId; } } public int SortOrder { - get { return _document.SortOrder; } + get { return _publishedContent.SortOrder; } } public string Name { - get { return _document.Name; } + get { return _publishedContent.Name; } } public bool Visible @@ -883,84 +883,84 @@ namespace Umbraco.Core.Dynamics public string UrlName { - get { return _document.UrlName; } + get { return _publishedContent.UrlName; } } public string DocumentTypeAlias { - get { return _document.DocumentTypeAlias; } + get { return _publishedContent.DocumentTypeAlias; } } public string WriterName { - get { return _document.WriterName; } + get { return _publishedContent.WriterName; } } public string CreatorName { - get { return _document.CreatorName; } + get { return _publishedContent.CreatorName; } } public int WriterId { - get { return _document.WriterId; } + get { return _publishedContent.WriterId; } } public int CreatorId { - get { return _document.CreatorId; } + get { return _publishedContent.CreatorId; } } public string Path { - get { return _document.Path; } + get { return _publishedContent.Path; } } public DateTime CreateDate { - get { return _document.CreateDate; } + get { return _publishedContent.CreateDate; } } public int Id { - get { return _document.Id; } + get { return _publishedContent.Id; } } public DateTime UpdateDate { - get { return _document.UpdateDate; } + get { return _publishedContent.UpdateDate; } } public Guid Version { - get { return _document.Version; } + get { return _publishedContent.Version; } } public int Level { - get { return _document.Level; } + get { return _publishedContent.Level; } } public IEnumerable Properties { - get { return _document.Properties; } + get { return _publishedContent.Properties; } } - public IEnumerable Children + public IEnumerable Children { get { if (_cachedChildren == null) { - var children = _document.Children; + var children = _publishedContent.Children; //testing, think this must be a special case for the root node ? - if (!children.Any() && _document.Id == 0) + if (!children.Any() && _publishedContent.Id == 0) { - _cachedChildren = new DynamicDocumentList(new List { new DynamicDocument(this._document) }); + _cachedChildren = new DynamicDocumentList(new List { new DynamicPublishedContent(this._publishedContent) }); } else { - _cachedChildren = new DynamicDocumentList(_document.Children.Select(x => new DynamicDocument(x))); + _cachedChildren = new DynamicDocumentList(_publishedContent.Children.Select(x => new DynamicPublishedContent(x))); } } return _cachedChildren; @@ -1046,7 +1046,7 @@ namespace Umbraco.Core.Dynamics } if (this.OwnerList != null) { - List container = this.OwnerList.Items.ToList(); + List container = this.OwnerList.Items.ToList(); int currentIndex = container.FindIndex(n => n.Id == this.Id); if (currentIndex != -1) { @@ -1273,99 +1273,99 @@ namespace Umbraco.Core.Dynamics { return IsHelper(n => n.Index() % 2 == 1, valueIfTrue, valueIfFalse); } - public bool IsEqual(DynamicDocument other) + public bool IsEqual(DynamicPublishedContent other) { return IsHelper(n => n.Id == other.Id); } - public HtmlString IsEqual(DynamicDocument other, string valueIfTrue) + public HtmlString IsEqual(DynamicPublishedContent other, string valueIfTrue) { return IsHelper(n => n.Id == other.Id, valueIfTrue); } - public HtmlString IsEqual(DynamicDocument other, string valueIfTrue, string valueIfFalse) + public HtmlString IsEqual(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse) { return IsHelper(n => n.Id == other.Id, valueIfTrue, valueIfFalse); } - public bool IsNotEqual(DynamicDocument other) + public bool IsNotEqual(DynamicPublishedContent other) { return IsHelper(n => n.Id != other.Id); } - public HtmlString IsNotEqual(DynamicDocument other, string valueIfTrue) + public HtmlString IsNotEqual(DynamicPublishedContent other, string valueIfTrue) { return IsHelper(n => n.Id != other.Id, valueIfTrue); } - public HtmlString IsNotEqual(DynamicDocument other, string valueIfTrue, string valueIfFalse) + public HtmlString IsNotEqual(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse) { return IsHelper(n => n.Id != other.Id, valueIfTrue, valueIfFalse); } - public bool IsDescendant(DynamicDocument other) + public bool IsDescendant(DynamicPublishedContent other) { var ancestors = this.Ancestors(); return IsHelper(n => ancestors.Items.Find(ancestor => ancestor.Id == other.Id) != null); } - public HtmlString IsDescendant(DynamicDocument other, string valueIfTrue) + public HtmlString IsDescendant(DynamicPublishedContent other, string valueIfTrue) { var ancestors = this.Ancestors(); return IsHelper(n => ancestors.Items.Find(ancestor => ancestor.Id == other.Id) != null, valueIfTrue); } - public HtmlString IsDescendant(DynamicDocument other, string valueIfTrue, string valueIfFalse) + public HtmlString IsDescendant(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse) { var ancestors = this.Ancestors(); return IsHelper(n => ancestors.Items.Find(ancestor => ancestor.Id == other.Id) != null, valueIfTrue, valueIfFalse); } - public bool IsDescendantOrSelf(DynamicDocument other) + public bool IsDescendantOrSelf(DynamicPublishedContent other) { var ancestors = this.AncestorsOrSelf(); return IsHelper(n => ancestors.Items.Find(ancestor => ancestor.Id == other.Id) != null); } - public HtmlString IsDescendantOrSelf(DynamicDocument other, string valueIfTrue) + public HtmlString IsDescendantOrSelf(DynamicPublishedContent other, string valueIfTrue) { var ancestors = this.AncestorsOrSelf(); return IsHelper(n => ancestors.Items.Find(ancestor => ancestor.Id == other.Id) != null, valueIfTrue); } - public HtmlString IsDescendantOrSelf(DynamicDocument other, string valueIfTrue, string valueIfFalse) + public HtmlString IsDescendantOrSelf(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse) { var ancestors = this.AncestorsOrSelf(); return IsHelper(n => ancestors.Items.Find(ancestor => ancestor.Id == other.Id) != null, valueIfTrue, valueIfFalse); } - public bool IsAncestor(DynamicDocument other) + public bool IsAncestor(DynamicPublishedContent other) { var descendants = this.Descendants(); return IsHelper(n => descendants.Items.Find(descendant => descendant.Id == other.Id) != null); } - public HtmlString IsAncestor(DynamicDocument other, string valueIfTrue) + public HtmlString IsAncestor(DynamicPublishedContent other, string valueIfTrue) { var descendants = this.Descendants(); return IsHelper(n => descendants.Items.Find(descendant => descendant.Id == other.Id) != null, valueIfTrue); } - public HtmlString IsAncestor(DynamicDocument other, string valueIfTrue, string valueIfFalse) + public HtmlString IsAncestor(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse) { var descendants = this.Descendants(); return IsHelper(n => descendants.Items.Find(descendant => descendant.Id == other.Id) != null, valueIfTrue, valueIfFalse); } - public bool IsAncestorOrSelf(DynamicDocument other) + public bool IsAncestorOrSelf(DynamicPublishedContent other) { var descendants = this.DescendantsOrSelf(); return IsHelper(n => descendants.Items.Find(descendant => descendant.Id == other.Id) != null); } - public HtmlString IsAncestorOrSelf(DynamicDocument other, string valueIfTrue) + public HtmlString IsAncestorOrSelf(DynamicPublishedContent other, string valueIfTrue) { var descendants = this.DescendantsOrSelf(); return IsHelper(n => descendants.Items.Find(descendant => descendant.Id == other.Id) != null, valueIfTrue); } - public HtmlString IsAncestorOrSelf(DynamicDocument other, string valueIfTrue, string valueIfFalse) + public HtmlString IsAncestorOrSelf(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse) { var descendants = this.DescendantsOrSelf(); return IsHelper(n => descendants.Items.Find(descendant => descendant.Id == other.Id) != null, valueIfTrue, valueIfFalse); } - public bool IsHelper(Func test) + public bool IsHelper(Func test) { return test(this); } - public HtmlString IsHelper(Func test, string valueIfTrue) + public HtmlString IsHelper(Func test, string valueIfTrue) { return IsHelper(test, valueIfTrue, string.Empty); } - public HtmlString IsHelper(Func test, string valueIfTrue, string valueIfFalse) + public HtmlString IsHelper(Func test, string valueIfTrue, string valueIfFalse) { return test(this) ? new HtmlString(valueIfTrue) : new HtmlString(valueIfFalse); } @@ -1390,7 +1390,7 @@ namespace Umbraco.Core.Dynamics //Totally gonna cheat here var dynamicDocumentList = new DynamicDocumentList(); dynamicDocumentList.Add(this); - var filtered = dynamicDocumentList.Where(predicate); + var filtered = dynamicDocumentList.Where(predicate); if (Queryable.Count(filtered) == 1) { //this node matches the predicate @@ -1411,105 +1411,105 @@ namespace Umbraco.Core.Dynamics // return base.ToString(); //} - #region Explicit IDocument implementation - IDocument IDocument.Parent + #region Explicit IPublishedContent implementation + IPublishedContent IPublishedContent.Parent { - get { return _document.Parent; } + get { return _publishedContent.Parent; } } - int IDocument.Id + int IPublishedContent.Id { - get { return _document.Id; } + get { return _publishedContent.Id; } } - int IDocument.TemplateId + int IPublishedContent.TemplateId { - get { return _document.TemplateId; } + get { return _publishedContent.TemplateId; } } - int IDocument.SortOrder + int IPublishedContent.SortOrder { - get { return _document.SortOrder; } + get { return _publishedContent.SortOrder; } } - string IDocument.Name + string IPublishedContent.Name { - get { return _document.Name; } + get { return _publishedContent.Name; } } - string IDocument.UrlName + string IPublishedContent.UrlName { - get { return _document.UrlName; } + get { return _publishedContent.UrlName; } } - string IDocument.DocumentTypeAlias + string IPublishedContent.DocumentTypeAlias { - get { return _document.DocumentTypeAlias; } + get { return _publishedContent.DocumentTypeAlias; } } - int IDocument.DocumentTypeId + int IPublishedContent.DocumentTypeId { - get { return _document.DocumentTypeId; } + get { return _publishedContent.DocumentTypeId; } } - string IDocument.WriterName + string IPublishedContent.WriterName { - get { return _document.WriterName; } + get { return _publishedContent.WriterName; } } - string IDocument.CreatorName + string IPublishedContent.CreatorName { - get { return _document.CreatorName; } + get { return _publishedContent.CreatorName; } } - int IDocument.WriterId + int IPublishedContent.WriterId { - get { return _document.WriterId; } + get { return _publishedContent.WriterId; } } - int IDocument.CreatorId + int IPublishedContent.CreatorId { - get { return _document.CreatorId; } + get { return _publishedContent.CreatorId; } } - string IDocument.Path + string IPublishedContent.Path { - get { return _document.Path; } + get { return _publishedContent.Path; } } - DateTime IDocument.CreateDate + DateTime IPublishedContent.CreateDate { - get { return _document.CreateDate; } + get { return _publishedContent.CreateDate; } } - DateTime IDocument.UpdateDate + DateTime IPublishedContent.UpdateDate { - get { return _document.UpdateDate; } + get { return _publishedContent.UpdateDate; } } - Guid IDocument.Version + Guid IPublishedContent.Version { - get { return _document.Version; } + get { return _publishedContent.Version; } } - int IDocument.Level + int IPublishedContent.Level { - get { return _document.Level; } + get { return _publishedContent.Level; } } - System.Collections.ObjectModel.Collection IDocument.Properties + System.Collections.ObjectModel.Collection IPublishedContent.Properties { - get { return _document.Properties; } + get { return _publishedContent.Properties; } } - IEnumerable IDocument.Children + IEnumerable IPublishedContent.Children { - get { return _document.Children; } + get { return _publishedContent.Children; } } - IDocumentProperty IDocument.GetProperty(string alias) + IDocumentProperty IPublishedContent.GetProperty(string alias) { - return _document.GetProperty(alias); + return _publishedContent.GetProperty(alias); } #endregion } diff --git a/src/Umbraco.Core/Dynamics/DynamicQueryable.cs b/src/Umbraco.Core/Dynamics/DynamicQueryable.cs index aadb6d3a98..1f82b55d2b 100644 --- a/src/Umbraco.Core/Dynamics/DynamicQueryable.cs +++ b/src/Umbraco.Core/Dynamics/DynamicQueryable.cs @@ -21,22 +21,22 @@ namespace Umbraco.Core.Dynamics if (source == null) throw new ArgumentNullException("source"); if (predicate == null) throw new ArgumentNullException("predicate"); LambdaExpression lambda = DynamicExpression.ParseLambda(source.ElementType, typeof(bool), predicate, true, values); - if (lambda.Parameters.Count > 0 && lambda.Parameters[0].Type == typeof(DynamicDocument)) + if (lambda.Parameters.Count > 0 && lambda.Parameters[0].Type == typeof(DynamicPublishedContent)) { //source list is DynamicNode and the lambda returns a Func - IQueryable typedSource = source as IQueryable; + IQueryable typedSource = source as IQueryable; var compiledFunc = lambda.Compile(); - Func func = null; - Func boolFunc = null; - if (compiledFunc is Func) + Func func = null; + Func boolFunc = null; + if (compiledFunc is Func) { - func = (Func)compiledFunc; + func = (Func)compiledFunc; } - if (compiledFunc is Func) + if (compiledFunc is Func) { - boolFunc = (Func)compiledFunc; + boolFunc = (Func)compiledFunc; } - return typedSource.Where(delegate(DynamicDocument node) + return typedSource.Where(delegate(DynamicPublishedContent node) { object value = -1; //value = func(node); @@ -46,13 +46,13 @@ namespace Umbraco.Core.Dynamics if (func != null) { var firstFuncResult = func(node); - if (firstFuncResult is Func) + if (firstFuncResult is Func) { - value = (firstFuncResult as Func)(node); + value = (firstFuncResult as Func)(node); } - if (firstFuncResult is Func) + if (firstFuncResult is Func) { - value = (firstFuncResult as Func)(node); + value = (firstFuncResult as Func)(node); } if (firstFuncResult is bool) { @@ -86,28 +86,28 @@ namespace Umbraco.Core.Dynamics } } - public static IQueryable Select(this IQueryable source, string selector, params object[] values) + public static IQueryable Select(this IQueryable source, string selector, params object[] values) { if (source == null) throw new ArgumentNullException("source"); if (selector == null) throw new ArgumentNullException("selector"); LambdaExpression lambda = DynamicExpression.ParseLambda(source.ElementType, typeof(object), selector, false, values); - if (lambda.Parameters.Count > 0 && lambda.Parameters[0].Type == typeof(DynamicDocument)) + if (lambda.Parameters.Count > 0 && lambda.Parameters[0].Type == typeof(DynamicPublishedContent)) { //source list is DynamicNode and the lambda returns a Func - IQueryable typedSource = source as IQueryable; + IQueryable typedSource = source as IQueryable; var compiledFunc = lambda.Compile(); - Func func = null; - if (compiledFunc is Func) + Func func = null; + if (compiledFunc is Func) { - func = (Func)compiledFunc; + func = (Func)compiledFunc; } - return typedSource.Select(delegate(DynamicDocument node) + return typedSource.Select(delegate(DynamicPublishedContent node) { object value = null; value = func(node); - if (value is Func) + if (value is Func) { - var innerValue = (value as Func)(node); + var innerValue = (value as Func)(node); return innerValue; } return value; @@ -133,7 +133,7 @@ namespace Umbraco.Core.Dynamics if (source == null) throw new ArgumentNullException("source"); if (ordering == null) throw new ArgumentNullException("ordering"); - IQueryable typedSource = source as IQueryable; + IQueryable typedSource = source as IQueryable; if (!ordering.Contains(",")) { bool descending = false; @@ -149,10 +149,10 @@ namespace Umbraco.Core.Dynamics } LambdaExpression lambda = DynamicExpression.ParseLambda(source.ElementType, typeof(object), ordering, false, values); - if (lambda.Parameters.Count > 0 && lambda.Parameters[0].Type == typeof(DynamicDocument)) + if (lambda.Parameters.Count > 0 && lambda.Parameters[0].Type == typeof(DynamicPublishedContent)) { //source list is DynamicNode and the lambda returns a Func - Func func = (Func)lambda.Compile(); + Func func = (Func)lambda.Compile(); //get the values out var query = typedSource.ToList().ConvertAll(item => new { node = item, key = EvaluateDynamicNodeFunc(item, func) }); if (query.Count == 0) @@ -246,13 +246,13 @@ namespace Umbraco.Core.Dynamics return null; } } - private static object EvaluateDynamicNodeFunc(DynamicDocument document, Func func) + private static object EvaluateDynamicNodeFunc(DynamicPublishedContent publishedContent, Func func) { object value = -1; - var firstFuncResult = func(document); - if (firstFuncResult is Func) + var firstFuncResult = func(publishedContent); + if (firstFuncResult is Func) { - value = (firstFuncResult as Func)(document); + value = (firstFuncResult as Func)(publishedContent); } if (firstFuncResult.GetType().IsValueType || firstFuncResult is string) { diff --git a/src/Umbraco.Core/Dynamics/ExpressionParser.cs b/src/Umbraco.Core/Dynamics/ExpressionParser.cs index a3cbb5803a..b8dff83b78 100644 --- a/src/Umbraco.Core/Dynamics/ExpressionParser.cs +++ b/src/Umbraco.Core/Dynamics/ExpressionParser.cs @@ -507,7 +507,7 @@ namespace Umbraco.Core.Dynamics (expr as LambdaExpression).Parameters.CopyTo(parameters, 0); var invokedExpr = Expression.Invoke(expr, parameters); var not = Expression.Not(Expression.TypeAs(invokedExpr, typeof(Nullable))); - expr = Expression.Lambda>( + expr = Expression.Lambda>( Expression.Condition( Expression.Property(not, "HasValue"), Expression.Property(not, "Value"), @@ -854,11 +854,11 @@ namespace Umbraco.Core.Dynamics Expression[] args = ParseArgumentList(); MethodBase mb; LambdaExpression instanceAsString = null; - ParameterExpression instanceExpression = Expression.Parameter(typeof(DynamicDocument), "instance"); + ParameterExpression instanceExpression = Expression.Parameter(typeof(DynamicPublishedContent), "instance"); if (type.IsGenericType && type != typeof(string)) { var typeArgs = type.GetGenericArguments(); - if (typeArgs[0] == typeof(DynamicDocument)) + if (typeArgs[0] == typeof(DynamicPublishedContent)) { if (instance != null && instance is LambdaExpression) { @@ -929,14 +929,14 @@ namespace Umbraco.Core.Dynamics //this will invoke TryGetMember (but wrapped in an expression tree) //so that when it's evaluated, DynamicNode should be supported - ParameterExpression instanceExpression = Expression.Parameter(typeof(DynamicDocument), "instance"); + ParameterExpression instanceExpression = Expression.Parameter(typeof(DynamicPublishedContent), "instance"); ParameterExpression convertDynamicNullToBooleanFalse = Expression.Parameter(typeof(bool), "convertDynamicNullToBooleanFalse"); ParameterExpression result = Expression.Parameter(typeof(object), "result"); ParameterExpression binder = Expression.Variable(typeof(DynamicQueryableGetMemberBinder), "binder"); ParameterExpression ignoreCase = Expression.Variable(typeof(bool), "ignoreCase"); ConstructorInfo getMemberBinderConstructor = typeof(DynamicQueryableGetMemberBinder).GetConstructor(new Type[] { typeof(string), typeof(bool) }); LabelTarget blockReturnLabel = Expression.Label(typeof(object)); - MethodInfo method = typeof(DynamicDocument).GetMethod("TryGetMember"); + MethodInfo method = typeof(DynamicPublishedContent).GetMethod("TryGetMember"); BlockExpression block = Expression.Block( typeof(object), @@ -957,10 +957,10 @@ namespace Umbraco.Core.Dynamics Expression.Return(blockReturnLabel, result), Expression.Label(blockReturnLabel, Expression.Constant(-2, typeof(object))) ); - LambdaExpression lax = Expression.Lambda>(block, instanceExpression); + LambdaExpression lax = Expression.Lambda>(block, instanceExpression); return lax; } - if (typeof(Func).IsAssignableFrom(type)) + if (typeof(Func).IsAssignableFrom(type)) { //accessing a property off an already resolved DynamicNode TryGetMember call //e.g. uBlogsyPostDate.Date @@ -971,8 +971,8 @@ namespace Umbraco.Core.Dynamics ParameterExpression result = Expression.Parameter(typeof(object), "result"); ParameterExpression idParam = Expression.Parameter(typeof(string), "id"); ParameterExpression lambdaResult = Expression.Parameter(typeof(object), "lambdaResult"); - ParameterExpression lambdaInstanceExpression = Expression.Parameter(typeof(DynamicDocument), "lambdaInstanceExpression"); - ParameterExpression instanceExpression = Expression.Parameter(typeof(Func), "instance"); + ParameterExpression lambdaInstanceExpression = Expression.Parameter(typeof(DynamicPublishedContent), "lambdaInstanceExpression"); + ParameterExpression instanceExpression = Expression.Parameter(typeof(Func), "instance"); LabelTarget blockReturnLabel = Expression.Label(typeof(object)); BlockExpression block = Expression.Block( @@ -991,7 +991,7 @@ namespace Umbraco.Core.Dynamics Expression.Return(blockReturnLabel, result), Expression.Label(blockReturnLabel, Expression.Constant(-2, typeof(object))) ); - LambdaExpression lax = Expression.Lambda>(block, lambdaInstanceExpression); + LambdaExpression lax = Expression.Lambda>(block, lambdaInstanceExpression); return lax; } } @@ -1050,11 +1050,11 @@ namespace Umbraco.Core.Dynamics switch (methodReturnType.Name) { case "String": - return Expression.Lambda>(block, instanceExpression); + return Expression.Lambda>(block, instanceExpression); case "Int32": - return Expression.Lambda>(block, instanceExpression); + return Expression.Lambda>(block, instanceExpression); case "Boolean": - return Expression.Lambda>(block, instanceExpression); + return Expression.Lambda>(block, instanceExpression); } return Expression.Call(instance, (MethodInfo)method, args); } @@ -1092,8 +1092,8 @@ namespace Umbraco.Core.Dynamics Expression.Return(cblockReturnLabel, cresult), Expression.Label(cblockReturnLabel, Expression.Constant(null, typeof(string)))); - LambdaExpression lax2 = Expression.Lambda>(cblock, instanceExpression); - var expression = Expression.Lambda>(cblock, instanceExpression); + LambdaExpression lax2 = Expression.Lambda>(cblock, instanceExpression); + var expression = Expression.Lambda>(cblock, instanceExpression); return expression; } @@ -1410,7 +1410,7 @@ namespace Umbraco.Core.Dynamics //if the type of the expression is a func - invokable returning object, //we are going to return it here, because we can get the real value when we actually have the instance //if (typeof(Func).IsAssignableFrom(expr.Type)) return expr; - if (expr is LambdaExpression && ((LambdaExpression)expr).Parameters.Count > 0 && ((LambdaExpression)expr).Parameters[0].Type == typeof(DynamicDocument)) + if (expr is LambdaExpression && ((LambdaExpression)expr).Parameters.Count > 0 && ((LambdaExpression)expr).Parameters[0].Type == typeof(DynamicPublishedContent)) { return expr; } @@ -1689,12 +1689,12 @@ namespace Umbraco.Core.Dynamics UnaryExpression unboxedLeft = null, unboxedRight = null; ParameterExpression[] parameters = null; - if (left is LambdaExpression && (left as LambdaExpression).Type.GetGenericArguments().First() == typeof(DynamicDocument)) + if (left is LambdaExpression && (left as LambdaExpression).Type.GetGenericArguments().First() == typeof(DynamicPublishedContent)) { leftIsLambda = true; } - if (right is LambdaExpression && (right as LambdaExpression).Type.GetGenericArguments().First() == typeof(DynamicDocument)) + if (right is LambdaExpression && (right as LambdaExpression).Type.GetGenericArguments().First() == typeof(DynamicPublishedContent)) { rightIsLambda = true; } @@ -1748,11 +1748,11 @@ namespace Umbraco.Core.Dynamics if (expressionType == ExpressionType.AndAlso) { - return ExpressionExtensions.And(left as Expression>, right as Expression>); + return ExpressionExtensions.And(left as Expression>, right as Expression>); } if (expressionType == ExpressionType.OrElse) { - return ExpressionExtensions.Or(left as Expression>, right as Expression>); + return ExpressionExtensions.Or(left as Expression>, right as Expression>); } } @@ -1783,11 +1783,11 @@ namespace Umbraco.Core.Dynamics //left is invoked and unboxed to right's TOut, right was not boxed if (expressionType == ExpressionType.AndAlso) { - return ExpressionExtensions.And(right as Expression>, Expression.Lambda>(unboxedLeft, parameters) as Expression>); + return ExpressionExtensions.And(right as Expression>, Expression.Lambda>(unboxedLeft, parameters) as Expression>); } if (expressionType == ExpressionType.OrElse) { - return ExpressionExtensions.And(right as Expression>, Expression.Lambda>(unboxedLeft, parameters) as Expression>); + return ExpressionExtensions.And(right as Expression>, Expression.Lambda>(unboxedLeft, parameters) as Expression>); } } else @@ -1804,11 +1804,11 @@ namespace Umbraco.Core.Dynamics //right is invoked and unboxed to left's TOut, left was not boxed if (expressionType == ExpressionType.AndAlso) { - return ExpressionExtensions.And(left as Expression>, Expression.Lambda>(unboxedRight, parameters) as Expression>); + return ExpressionExtensions.And(left as Expression>, Expression.Lambda>(unboxedRight, parameters) as Expression>); } if (expressionType == ExpressionType.OrElse) { - return ExpressionExtensions.And(left as Expression>, Expression.Lambda>(unboxedRight, parameters) as Expression>); + return ExpressionExtensions.And(left as Expression>, Expression.Lambda>(unboxedRight, parameters) as Expression>); } } @@ -1879,7 +1879,7 @@ namespace Umbraco.Core.Dynamics break; case ExpressionType.Modulo: binaryExpression = Expression.Modulo(finalLeft, finalRight); - return (Expression.Lambda>(binaryExpression, parameters)); + return (Expression.Lambda>(binaryExpression, parameters)); case ExpressionType.AndAlso: if ((leftIsLambda && rightIsLambda && sequenceEqual) || (!leftIsLambda && !rightIsLambda)) { @@ -1887,7 +1887,7 @@ namespace Umbraco.Core.Dynamics } else { - return (Expression.Lambda>(Expression.AndAlso(finalLeft, finalRight), parameters)); + return (Expression.Lambda>(Expression.AndAlso(finalLeft, finalRight), parameters)); } case ExpressionType.OrElse: if (leftIsLambda && rightIsLambda && sequenceEqual || (!leftIsLambda && !rightIsLambda)) @@ -1896,7 +1896,7 @@ namespace Umbraco.Core.Dynamics } else { - return (Expression.Lambda>(Expression.OrElse(finalLeft, finalRight), parameters)); + return (Expression.Lambda>(Expression.OrElse(finalLeft, finalRight), parameters)); } default: return Expression.Equal(left, right); @@ -1904,7 +1904,7 @@ namespace Umbraco.Core.Dynamics if (leftIsLambda || rightIsLambda) { var body = Expression.Condition(Expression.TypeEqual(innerLeft, right.Type), binaryExpression, Expression.Constant(false)); - return Expression.Lambda>(body, parameters); + return Expression.Lambda>(body, parameters); } else { diff --git a/src/Umbraco.Core/Dynamics/ExtensionMethods.cs b/src/Umbraco.Core/Dynamics/ExtensionMethods.cs index e2879b115f..69e1d877da 100644 --- a/src/Umbraco.Core/Dynamics/ExtensionMethods.cs +++ b/src/Umbraco.Core/Dynamics/ExtensionMethods.cs @@ -47,7 +47,7 @@ namespace Umbraco.Core.Dynamics return new DynamicDocumentList(all.Items.OrderBy(x => Guid.NewGuid()).Take(max)); } - public static DynamicDocument Random(this DynamicDocumentList all) + public static DynamicPublishedContent Random(this DynamicDocumentList all) { return all.Items.OrderBy(x => Guid.NewGuid()).First(); } diff --git a/src/Umbraco.Core/Dynamics/Grouping.cs b/src/Umbraco.Core/Dynamics/Grouping.cs index 72e6504188..ff7d83549f 100644 --- a/src/Umbraco.Core/Dynamics/Grouping.cs +++ b/src/Umbraco.Core/Dynamics/Grouping.cs @@ -13,7 +13,7 @@ namespace Umbraco.Core.Dynamics public IEnumerator GetEnumerator() { - var temp = new DynamicDocumentList(Elements.Cast()); + var temp = new DynamicDocumentList(Elements.Cast()); return (IEnumerator)temp.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() @@ -42,7 +42,7 @@ namespace Umbraco.Core.Dynamics object key = null; (item as DynamicObject).TryGetMember(new DynamicQueryableGetMemberBinder(ordering, false), out key); return key; - }).Cast()); + }).Cast()); } else { @@ -51,7 +51,7 @@ namespace Umbraco.Core.Dynamics object key = null; (item as DynamicObject).TryGetMember(new DynamicQueryableGetMemberBinder(ordering, false), out key); return key; - }).Cast()); + }).Cast()); } } } diff --git a/src/Umbraco.Core/Dynamics/PropertyResultType.cs b/src/Umbraco.Core/Dynamics/PropertyResultType.cs index 8475e7dba6..d1ab0904f5 100644 --- a/src/Umbraco.Core/Dynamics/PropertyResultType.cs +++ b/src/Umbraco.Core/Dynamics/PropertyResultType.cs @@ -11,7 +11,7 @@ namespace Umbraco.Core.Dynamics UserProperty, /// - /// The property resolved was a property defined as a member on the document object (IDocument) itself + /// The property resolved was a property defined as a member on the document object (IPublishedContent) itself /// ReflectedProperty, diff --git a/src/Umbraco.Core/Models/IDocument.cs b/src/Umbraco.Core/Models/IPublishedContent.cs similarity index 81% rename from src/Umbraco.Core/Models/IDocument.cs rename to src/Umbraco.Core/Models/IPublishedContent.cs index 07d9b55317..c9695ad52a 100644 --- a/src/Umbraco.Core/Models/IDocument.cs +++ b/src/Umbraco.Core/Models/IPublishedContent.cs @@ -5,15 +5,15 @@ using System.Collections.ObjectModel; namespace Umbraco.Core.Models { /// - /// Defines a document in Umbraco + /// Defines a PublishedContent in Umbraco /// /// /// A replacement for INode which needs to occur since INode doesn't contain the document type alias /// and INode is poorly formatted with mutable properties (i.e. Lists instead of IEnumerable) /// - public interface IDocument + public interface IPublishedContent { - IDocument Parent { get; } + IPublishedContent Parent { get; } int Id { get; } int TemplateId { get; } int SortOrder { get; } @@ -31,7 +31,7 @@ namespace Umbraco.Core.Models Guid Version { get; } int Level { get; } Collection Properties { get; } - IEnumerable Children { get; } + IEnumerable Children { get; } /// /// Returns a property on the object based on an alias @@ -42,7 +42,7 @@ namespace Umbraco.Core.Models /// Although we do have a a property to return Properties of the object, in some cases a custom implementation may not know /// about all properties until specifically asked for one by alias. /// - /// This method is mostly used in places such as DynamicDocument when trying to resolve a property based on an alias. + /// This method is mostly used in places such as DynamicPublishedContent when trying to resolve a property based on an alias. /// In some cases Pulish Stores, a property value may exist in multiple places and we need to fallback to different cached locations /// therefore sometimes the 'Properties' collection may not be sufficient. /// diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index c7778a7bd1..c19c511dd0 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -68,7 +68,7 @@ - + @@ -101,7 +101,7 @@ - + diff --git a/src/Umbraco.Tests/ContentStores/PublishMediaStoreTests.cs b/src/Umbraco.Tests/ContentStores/PublishMediaStoreTests.cs index 960fde1891..b9cc5c485d 100644 --- a/src/Umbraco.Tests/ContentStores/PublishMediaStoreTests.cs +++ b/src/Umbraco.Tests/ContentStores/PublishMediaStoreTests.cs @@ -60,7 +60,7 @@ namespace Umbraco.Tests var child1 = GetDictionaryDocument(idVal: 222333); var child2 = GetDictionaryDocument(idVal: 444555); - var dicDoc = GetDictionaryDocument(children: new List() + var dicDoc = GetDictionaryDocument(children: new List() { child1, child2 }); @@ -169,7 +169,7 @@ namespace Umbraco.Tests }; } - private DefaultPublishedMediaStore.DictionaryDocument GetDictionaryDocument( + private DefaultPublishedMediaStore.DictionaryPublishedContent GetDictionaryDocument( string idKey = "id", string templateKey = "template", string nodeNameKey = "nodeName", @@ -177,20 +177,20 @@ namespace Umbraco.Tests string pathKey = "path", int idVal = 1234, int parentIdVal = 321, - IEnumerable children = null) + IEnumerable children = null) { if (children == null) - children = new List(); - var dicDoc = new DefaultPublishedMediaStore.DictionaryDocument( + children = new List(); + var dicDoc = new DefaultPublishedMediaStore.DictionaryPublishedContent( //the dictionary GetDictionary(idVal, parentIdVal, idKey, templateKey, nodeNameKey, nodeTypeAliasKey, pathKey), //callback to get the parent - d => new DefaultPublishedMediaStore.DictionaryDocument( + d => new DefaultPublishedMediaStore.DictionaryPublishedContent( GetDictionary(parentIdVal, -1, idKey, templateKey, nodeNameKey, nodeTypeAliasKey, pathKey), //there is no parent a => null, //we're not going to test this so ignore - a => new List(), + a => new List(), (dd, a) => dd.Properties.FirstOrDefault(x => x.Alias.InvariantEquals(a))), //callback to get the children d => children, @@ -199,7 +199,7 @@ namespace Umbraco.Tests } private void DoAssert( - DefaultPublishedMediaStore.DictionaryDocument dicDoc, + DefaultPublishedMediaStore.DictionaryPublishedContent dicDoc, int idVal = 1234, int templateIdVal = 333, int sortOrderVal = 44, @@ -221,15 +221,15 @@ namespace Umbraco.Tests if (!updateDateVal.HasValue) updateDateVal = DateTime.Parse("2012-01-03"); - DoAssert((IDocument)dicDoc, idVal, templateIdVal, sortOrderVal, urlNameVal, nodeTypeAliasVal, nodeTypeIdVal, writerNameVal, + DoAssert((IPublishedContent)dicDoc, idVal, templateIdVal, sortOrderVal, urlNameVal, nodeTypeAliasVal, nodeTypeIdVal, writerNameVal, creatorNameVal, writerIdVal, creatorIdVal, pathVal, createDateVal, updateDateVal, levelVal); - //now validate the parentId that has been parsed, this doesn't exist on the IDocument + //now validate the parentId that has been parsed, this doesn't exist on the IPublishedContent Assert.AreEqual(parentIdVal, dicDoc.ParentId); } private void DoAssert( - IDocument doc, + IPublishedContent doc, int idVal = 1234, int templateIdVal = 333, int sortOrderVal = 44, diff --git a/src/Umbraco.Tests/DynamicDocument/DocumentTests.cs b/src/Umbraco.Tests/DynamicDocument/DocumentTests.cs index a5c081f7e3..edf68d6b71 100644 --- a/src/Umbraco.Tests/DynamicDocument/DocumentTests.cs +++ b/src/Umbraco.Tests/DynamicDocument/DocumentTests.cs @@ -12,7 +12,7 @@ using Umbraco.Web; namespace Umbraco.Tests.DynamicDocument { /// - /// Unit tests for IDocument and extensions + /// Unit tests for IPublishedContent and extensions /// [TestFixture] public class DocumentTests : BaseRoutingTest @@ -92,7 +92,7 @@ namespace Umbraco.Tests.DynamicDocument { var doc = GetDocument(true, 1); //change a doc type alias - ((TestDocument) doc.Children.ElementAt(0)).DocumentTypeAlias = "DontMatch"; + ((TestPublishedContent) doc.Children.ElementAt(0)).DocumentTypeAlias = "DontMatch"; var dt = doc.ChildrenAsTable("Child"); @@ -116,9 +116,9 @@ namespace Umbraco.Tests.DynamicDocument Assert.AreEqual(0, dt.Rows.Count); } - private IDocument GetDocument(bool createChildren, int indexVals) + private IPublishedContent GetDocument(bool createChildren, int indexVals) { - var d = new TestDocument + var d = new TestPublishedContent { CreateDate = DateTime.Now, CreatorId = 1, @@ -143,11 +143,11 @@ namespace Umbraco.Tests.DynamicDocument new PropertyResult("property1", "value" + indexVals, Guid.NewGuid(), PropertyResultType.UserProperty), new PropertyResult("property2", "value" + (indexVals + 1), Guid.NewGuid(), PropertyResultType.UserProperty) }), - Children = new List() + Children = new List() }; if (createChildren) { - d.Children = new List() + d.Children = new List() { GetDocument(false, indexVals + 3), GetDocument(false, indexVals + 6), @@ -167,9 +167,9 @@ namespace Umbraco.Tests.DynamicDocument } - private class TestDocument : IDocument + private class TestPublishedContent : IPublishedContent { - public IDocument Parent { get; set; } + public IPublishedContent Parent { get; set; } public int Id { get; set; } public int TemplateId { get; set; } public int SortOrder { get; set; } @@ -187,7 +187,7 @@ namespace Umbraco.Tests.DynamicDocument public Guid Version { get; set; } public int Level { get; set; } public Collection Properties { get; set; } - public IEnumerable Children { get; set; } + public IEnumerable Children { get; set; } public IDocumentProperty GetProperty(string alias) { return Properties.FirstOrDefault(x => x.Alias.InvariantEquals(alias)); diff --git a/src/Umbraco.Tests/DynamicDocument/DynamicDocumentCustomExtensionMethods.cs b/src/Umbraco.Tests/DynamicDocument/DynamicDocumentCustomExtensionMethods.cs index 8c7f8af33f..a1d55025dd 100644 --- a/src/Umbraco.Tests/DynamicDocument/DynamicDocumentCustomExtensionMethods.cs +++ b/src/Umbraco.Tests/DynamicDocument/DynamicDocumentCustomExtensionMethods.cs @@ -6,17 +6,17 @@ namespace Umbraco.Tests.DynamicDocument public static class DynamicDocumentCustomExtensionMethods { - public static string DynamicDocumentNoParameters(this Core.Dynamics.DynamicDocument doc) + public static string DynamicDocumentNoParameters(this Core.Dynamics.DynamicPublishedContent doc) { return "Hello world"; } - public static string DynamicDocumentCustomString(this Core.Dynamics.DynamicDocument doc, string custom) + public static string DynamicDocumentCustomString(this Core.Dynamics.DynamicPublishedContent doc, string custom) { return custom; } - public static string DynamicDocumentMultiParam(this Core.Dynamics.DynamicDocument doc, string custom, int i, bool b) + public static string DynamicDocumentMultiParam(this Core.Dynamics.DynamicPublishedContent doc, string custom, int i, bool b) { return custom + i + b; } @@ -26,7 +26,7 @@ namespace Umbraco.Tests.DynamicDocument return custom + i + b; } - public static string DynamicDocumentEnumerableMultiParam(this IEnumerable doc, string custom, int i, bool b) + public static string DynamicDocumentEnumerableMultiParam(this IEnumerable doc, string custom, int i, bool b) { return custom + i + b; } diff --git a/src/Umbraco.Tests/DynamicDocument/DynamicDocumentTests.cs b/src/Umbraco.Tests/DynamicDocument/DynamicDocumentTests.cs index 447aa96d29..176b7a3b9d 100644 --- a/src/Umbraco.Tests/DynamicDocument/DynamicDocumentTests.cs +++ b/src/Umbraco.Tests/DynamicDocument/DynamicDocumentTests.cs @@ -14,7 +14,7 @@ using umbraco.cms.businesslogic.web; namespace Umbraco.Tests.DynamicDocument { [TestFixture] - public class DynamicDocumentTests : DynamicDocumentTestsBase + public class DynamicDocumentTests : DynamicDocumentTestsBase { public override void Initialize() { @@ -36,7 +36,7 @@ namespace Umbraco.Tests.DynamicDocument PropertyEditorValueConvertersResolver.Reset(); } - internal Core.Dynamics.DynamicDocument GetNode(int id) + internal Core.Dynamics.DynamicPublishedContent GetNode(int id) { //var template = Template.MakeNew("test", new User(0)); //var ctx = GetUmbracoContext("/test", template.Id); @@ -44,7 +44,7 @@ namespace Umbraco.Tests.DynamicDocument var contentStore = new DefaultPublishedContentStore(); var doc = contentStore.GetDocumentById(ctx, id); Assert.IsNotNull(doc); - var dynamicNode = new Core.Dynamics.DynamicDocument(doc); + var dynamicNode = new Core.Dynamics.DynamicPublishedContent(doc); Assert.IsNotNull(dynamicNode); return dynamicNode; } @@ -71,7 +71,7 @@ namespace Umbraco.Tests.DynamicDocument { var helper = new TestHelper(GetNode(1173)); var doc = helper.GetDoc(); - //HasProperty is only a prop on DynamicDocument, NOT IDocument + //HasProperty is only a prop on DynamicPublishedContent, NOT IPublishedContent Assert.IsFalse(doc.GetType().GetProperties().Any(x => x.Name == "HasProperty")); } @@ -80,7 +80,7 @@ namespace Umbraco.Tests.DynamicDocument { var helper = new TestHelper(GetNode(1173)); var doc = helper.GetDocAsDynamic(); - //HasProperty is only a prop on DynamicDocument, NOT IDocument + //HasProperty is only a prop on DynamicPublishedContent, NOT IPublishedContent Assert.IsTrue(doc.HasProperty("umbracoUrlAlias")); } @@ -90,7 +90,7 @@ namespace Umbraco.Tests.DynamicDocument var helper = new TestHelper(GetNode(1173)); var doc = helper.GetDoc(); var ddoc = (dynamic) doc; - //HasProperty is only a prop on DynamicDocument, NOT IDocument + //HasProperty is only a prop on DynamicPublishedContent, NOT IPublishedContent Assert.IsTrue(ddoc.HasProperty("umbracoUrlAlias")); } @@ -99,14 +99,14 @@ namespace Umbraco.Tests.DynamicDocument /// public class TestHelper { - private readonly Core.Dynamics.DynamicDocument _doc; + private readonly Core.Dynamics.DynamicPublishedContent _doc; - public TestHelper(Core.Dynamics.DynamicDocument doc) + public TestHelper(Core.Dynamics.DynamicPublishedContent doc) { _doc = doc; } - public IDocument GetDoc() + public IPublishedContent GetDoc() { return _doc; } diff --git a/src/Umbraco.Tests/Routing/LookupByNiceUrlAndTemplateTests.cs b/src/Umbraco.Tests/Routing/LookupByNiceUrlAndTemplateTests.cs index 412fb03c0b..f5effa4be5 100644 --- a/src/Umbraco.Tests/Routing/LookupByNiceUrlAndTemplateTests.cs +++ b/src/Umbraco.Tests/Routing/LookupByNiceUrlAndTemplateTests.cs @@ -26,7 +26,7 @@ namespace Umbraco.Tests.Routing var result = lookup.TrySetDocument(docRequest); Assert.IsTrue(result); - Assert.IsNotNull(docRequest.Document); + Assert.IsNotNull(docRequest.PublishedContent); Assert.IsNotNull(docRequest.Template); Assert.AreEqual("blah".ToUpperInvariant(), docRequest.Template.Alias.ToUpperInvariant()); } diff --git a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs index 2e8e3b08f4..91bdee7291 100644 --- a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs +++ b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs @@ -41,7 +41,7 @@ namespace Umbraco.Tests.Routing var routingContext = GetRoutingContext("~/dummy-page", template, routeData); var docRequest = new DocumentRequest(routingContext.UmbracoContext.UmbracoUrl, routingContext) { - Document = routingContext.PublishedContentStore.GetDocumentById(routingContext.UmbracoContext, 1174), + PublishedContent = routingContext.PublishedContentStore.GetDocumentById(routingContext.UmbracoContext, 1174), Template = template }; @@ -65,7 +65,7 @@ namespace Umbraco.Tests.Routing var routingContext = GetRoutingContext("~/dummy-page", template, routeData); var docRequest = new DocumentRequest(routingContext.UmbracoContext.UmbracoUrl, routingContext) { - Document = routingContext.PublishedContentStore.GetDocumentById(routingContext.UmbracoContext, 1172), + PublishedContent = routingContext.PublishedContentStore.GetDocumentById(routingContext.UmbracoContext, 1172), Template = template }; diff --git a/src/Umbraco.Web/DefaultPublishedContentStore.cs b/src/Umbraco.Web/DefaultPublishedContentStore.cs index 719dea972c..d5c0c1cd31 100644 --- a/src/Umbraco.Web/DefaultPublishedContentStore.cs +++ b/src/Umbraco.Web/DefaultPublishedContentStore.cs @@ -17,22 +17,22 @@ namespace Umbraco.Web internal class DefaultPublishedContentStore : IPublishedContentStore { - private IDocument ConvertToDocument(XmlNode xmlNode) + private IPublishedContent ConvertToDocument(XmlNode xmlNode) { if (xmlNode == null) return null; - return new Models.XmlDocument(xmlNode); + return new Models.XmlPublishedContent(xmlNode); } - public virtual IDocument GetDocumentById(UmbracoContext umbracoContext, int nodeId) + public virtual IPublishedContent GetDocumentById(UmbracoContext umbracoContext, int nodeId) { if (umbracoContext == null) throw new ArgumentNullException("umbracoContext"); return ConvertToDocument(GetXml(umbracoContext).GetElementById(nodeId.ToString())); } - public IDocument GetDocumentByRoute(UmbracoContext umbracoContext, string route, bool? hideTopLevelNode = null) + public IPublishedContent GetDocumentByRoute(UmbracoContext umbracoContext, string route, bool? hideTopLevelNode = null) { if (umbracoContext == null) throw new ArgumentNullException("umbracoContext"); if (route == null) throw new ArgumentNullException("route"); @@ -64,7 +64,7 @@ namespace Umbraco.Web return ConvertToDocument(found); } - public IDocument GetDocumentByUrlAlias(UmbracoContext umbracoContext, int rootNodeId, string alias) + public IPublishedContent GetDocumentByUrlAlias(UmbracoContext umbracoContext, int rootNodeId, string alias) { if (umbracoContext == null) throw new ArgumentNullException("umbracoContext"); if (alias == null) throw new ArgumentNullException("alias"); diff --git a/src/Umbraco.Web/DefaultPublishedMediaStore.cs b/src/Umbraco.Web/DefaultPublishedMediaStore.cs index 05d797a6b7..344964da6e 100644 --- a/src/Umbraco.Web/DefaultPublishedMediaStore.cs +++ b/src/Umbraco.Web/DefaultPublishedMediaStore.cs @@ -21,12 +21,12 @@ namespace Umbraco.Web /// internal class DefaultPublishedMediaStore : IPublishedMediaStore { - public virtual IDocument GetDocumentById(UmbracoContext umbracoContext, int nodeId) + public virtual IPublishedContent GetDocumentById(UmbracoContext umbracoContext, int nodeId) { return GetUmbracoMedia(nodeId); } - private IDocument GetUmbracoMedia(int id) + private IPublishedContent GetUmbracoMedia(int id) { try @@ -62,7 +62,7 @@ namespace Umbraco.Web return null; } - internal IDocument ConvertFromSearchResult(SearchResult searchResult) + internal IPublishedContent ConvertFromSearchResult(SearchResult searchResult) { //TODO: Some fields will not be included, that just the way it is unfortunatley until this is fixed: // http://examine.codeplex.com/workitem/10350 @@ -91,7 +91,7 @@ namespace Umbraco.Web } - return new DictionaryDocument(values, + return new DictionaryPublishedContent(values, d => d.ParentId != -1 //parent should be null if -1 ? GetUmbracoMedia(d.ParentId) : null, @@ -103,7 +103,7 @@ namespace Umbraco.Web }; } - internal IDocument ConvertFromXPathNavigator(XPathNavigator xpath) + internal IPublishedContent ConvertFromXPathNavigator(XPathNavigator xpath) { if (xpath == null) throw new ArgumentNullException("xpath"); @@ -151,7 +151,7 @@ namespace Umbraco.Web } } - return new DictionaryDocument(values, + return new DictionaryPublishedContent(values, d => d.ParentId != -1 //parent should be null if -1 ? GetUmbracoMedia(d.ParentId) : null, @@ -167,7 +167,7 @@ namespace Umbraco.Web /// /// /// - private IDocumentProperty GetProperty(DictionaryDocument dd, string alias) + private IDocumentProperty GetProperty(DictionaryPublishedContent dd, string alias) { if (dd.LoadedFromExamine) { @@ -210,7 +210,7 @@ namespace Umbraco.Web /// /// /// - private IEnumerable GetChildrenMedia(int parentId, XPathNavigator xpath = null) + private IEnumerable GetChildrenMedia(int parentId, XPathNavigator xpath = null) { //if there is no navigator, try examine first, then re-look it up @@ -248,7 +248,7 @@ namespace Umbraco.Web } var children = xpath.SelectChildren(XPathNodeType.Element); - var mediaList = new List(); + var mediaList = new List(); while (children.Current != null) { if (!children.MoveNext()) @@ -272,20 +272,20 @@ namespace Umbraco.Web } /// - /// An IDocument that is represented all by a dictionary. + /// An IPublishedContent that is represented all by a dictionary. /// /// /// This is a helper class and definitely not intended for public use, it expects that all of the values required - /// to create an IDocument exist in the dictionary by specific aliases. + /// to create an IPublishedContent exist in the dictionary by specific aliases. /// - internal class DictionaryDocument : IDocument + internal class DictionaryPublishedContent : IPublishedContent { - public DictionaryDocument( + public DictionaryPublishedContent( IDictionary valueDictionary, - Func getParent, - Func> getChildren, - Func getProperty) + Func getParent, + Func> getChildren, + Func getProperty) { if (valueDictionary == null) throw new ArgumentNullException("valueDictionary"); if (getParent == null) throw new ArgumentNullException("getParent"); @@ -339,11 +339,11 @@ namespace Umbraco.Web /// internal bool LoadedFromExamine { get; set; } - private readonly Func _getParent; - private readonly Func> _getChildren; - private readonly Func _getProperty; + private readonly Func _getParent; + private readonly Func> _getChildren; + private readonly Func _getProperty; - public IDocument Parent + public IPublishedContent Parent { get { return _getParent(this); } } @@ -366,7 +366,7 @@ namespace Umbraco.Web public Guid Version { get; private set; } public int Level { get; private set; } public Collection Properties { get; private set; } - public IEnumerable Children + public IEnumerable Children { get { return _getChildren(this); } } diff --git a/src/Umbraco.Web/DocumentExtensions.cs b/src/Umbraco.Web/DocumentExtensions.cs index bf63757645..a2e783e1ec 100644 --- a/src/Umbraco.Web/DocumentExtensions.cs +++ b/src/Umbraco.Web/DocumentExtensions.cs @@ -10,7 +10,7 @@ using Umbraco.Core; namespace Umbraco.Web { /// - /// Extension methods for IDocument + /// Extension methods for IPublishedContent /// /// /// These methods exist in the web project as we need access to web based classes like NiceUrl provider @@ -20,23 +20,23 @@ namespace Umbraco.Web { /// - /// Returns a DataTable object for the IDocument + /// Returns a DataTable object for the IPublishedContent /// /// /// /// - public static DataTable ChildrenAsTable(this IDocument d, string nodeTypeAliasFilter = "") + public static DataTable ChildrenAsTable(this IPublishedContent d, string nodeTypeAliasFilter = "") { return GenerateDataTable(d, nodeTypeAliasFilter); } /// - /// Generates the DataTable for the IDocument + /// Generates the DataTable for the IPublishedContent /// /// /// /// - private static DataTable GenerateDataTable(IDocument node, string nodeTypeAliasFilter = "") + private static DataTable GenerateDataTable(IPublishedContent node, string nodeTypeAliasFilter = "") { var firstNode = nodeTypeAliasFilter.IsNullOrWhiteSpace() ? node.Children.Any() diff --git a/src/Umbraco.Web/DynamicDocumentSearchExtensions.cs b/src/Umbraco.Web/DynamicDocumentSearchExtensions.cs index ebac0d8160..5babdca24b 100644 --- a/src/Umbraco.Web/DynamicDocumentSearchExtensions.cs +++ b/src/Umbraco.Web/DynamicDocumentSearchExtensions.cs @@ -4,11 +4,11 @@ using Umbraco.Core.Dynamics; namespace Umbraco.Web { /// - /// DynamicDocument extension methods for searching using Examine + /// DynamicPublishedContent extension methods for searching using Examine /// public static class DynamicDocumentSearchExtensions { - public static DynamicDocumentList Search(this DynamicDocument d, string term, bool useWildCards = true, string searchProvider = null) + public static DynamicDocumentList 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 DynamicDocument d, string term, bool useWildCards = true, string searchProvider = null) + public static DynamicDocumentList SearchDescendants(this DynamicPublishedContent d, string term, bool useWildCards = true, string searchProvider = null) { return d.Search(term, useWildCards, searchProvider); } - public static DynamicDocumentList SearchChildren(this DynamicDocument d, string term, bool useWildCards = true, string searchProvider = null) + public static DynamicDocumentList 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 DynamicDocument d, Examine.SearchCriteria.ISearchCriteria criteria, Examine.Providers.BaseSearchProvider searchProvider = null) + public static DynamicDocumentList Search(this DynamicPublishedContent d, Examine.SearchCriteria.ISearchCriteria criteria, Examine.Providers.BaseSearchProvider searchProvider = null) { var s = Examine.ExamineManager.Instance.DefaultSearchProvider; if (searchProvider != null) diff --git a/src/Umbraco.Web/ExamineExtensions.cs b/src/Umbraco.Web/ExamineExtensions.cs index 5dc1e2dfd8..243230e03a 100644 --- a/src/Umbraco.Web/ExamineExtensions.cs +++ b/src/Umbraco.Web/ExamineExtensions.cs @@ -16,7 +16,7 @@ namespace Umbraco.Web this IEnumerable results, IPublishedStore store) { - //TODO: The search result has already returned a result which SHOULD include all of the data to create an IDocument, + //TODO: The search result has already returned a result which SHOULD include all of the data to create an IPublishedContent, // however thsi is currently not the case: // http://examine.codeplex.com/workitem/10350 @@ -31,7 +31,7 @@ namespace Umbraco.Web if (doc == null) continue; //skip if this doesn't exist in the cache doc.Properties.Add( new PropertyResult("examineScore", result.Score.ToString(), Guid.Empty, PropertyResultType.CustomProperty)); - var dynamicDoc = new DynamicDocument(doc); + var dynamicDoc = new DynamicPublishedContent(doc); list.Add(dynamicDoc); } return list; diff --git a/src/Umbraco.Web/IPublishedContentStore.cs b/src/Umbraco.Web/IPublishedContentStore.cs index c603b58c44..f785c165a9 100644 --- a/src/Umbraco.Web/IPublishedContentStore.cs +++ b/src/Umbraco.Web/IPublishedContentStore.cs @@ -7,8 +7,8 @@ namespace Umbraco.Web /// internal interface IPublishedContentStore : IPublishedStore { - IDocument GetDocumentByRoute(UmbracoContext umbracoContext, string route, bool? hideTopLevelNode = null); - IDocument GetDocumentByUrlAlias(UmbracoContext umbracoContext, int rootNodeId, string alias); + IPublishedContent GetDocumentByRoute(UmbracoContext umbracoContext, string route, bool? hideTopLevelNode = null); + IPublishedContent GetDocumentByUrlAlias(UmbracoContext umbracoContext, int rootNodeId, string alias); bool HasContent(UmbracoContext umbracoContext); } } \ No newline at end of file diff --git a/src/Umbraco.Web/IPublishedStore.cs b/src/Umbraco.Web/IPublishedStore.cs index c3867a1bff..dd2cc1031a 100644 --- a/src/Umbraco.Web/IPublishedStore.cs +++ b/src/Umbraco.Web/IPublishedStore.cs @@ -7,6 +7,6 @@ namespace Umbraco.Web /// public interface IPublishedStore { - IDocument GetDocumentById(UmbracoContext umbracoContext, int nodeId); + IPublishedContent GetDocumentById(UmbracoContext umbracoContext, int nodeId); } } \ No newline at end of file diff --git a/src/Umbraco.Web/Models/XmlDocument.cs b/src/Umbraco.Web/Models/XmlPublishedContent.cs similarity index 88% rename from src/Umbraco.Web/Models/XmlDocument.cs rename to src/Umbraco.Web/Models/XmlPublishedContent.cs index cf8aaaf32e..d603e2ef5a 100644 --- a/src/Umbraco.Web/Models/XmlDocument.cs +++ b/src/Umbraco.Web/Models/XmlPublishedContent.cs @@ -13,17 +13,17 @@ namespace Umbraco.Web.Models { /// - /// Represents an IDocument which is created based on an Xml structure + /// Represents an IPublishedContent which is created based on an Xml structure /// [Serializable] [XmlType(Namespace = "http://umbraco.org/webservices/")] - internal class XmlDocument : IDocument + internal class XmlPublishedContent : IPublishedContent { /// /// Constructor /// /// - public XmlDocument(XmlNode xmlNode) + public XmlPublishedContent(XmlNode xmlNode) { _pageXmlNode = xmlNode; InitializeStructure(); @@ -35,7 +35,7 @@ namespace Umbraco.Web.Models /// /// /// - internal XmlDocument(XmlNode xmlNode, bool disableInitializing) + internal XmlPublishedContent(XmlNode xmlNode, bool disableInitializing) { _pageXmlNode = xmlNode; InitializeStructure(); @@ -44,8 +44,8 @@ namespace Umbraco.Web.Models } private bool _initialized = false; - private readonly ICollection _children = new Collection(); - private IDocument _parent = null; + private readonly ICollection _children = new Collection(); + private IPublishedContent _parent = null; private int _id; private int _template; private string _name; @@ -65,7 +65,7 @@ namespace Umbraco.Web.Models private int _sortOrder; private int _level; - public IEnumerable Children + public IEnumerable Children { get { @@ -80,7 +80,7 @@ namespace Umbraco.Web.Models return Properties.FirstOrDefault(x => x.Alias.InvariantEquals(alias)); } - public IDocument Parent + public IPublishedContent Parent { get { @@ -270,7 +270,7 @@ namespace Umbraco.Web.Models { XmlNode parent = _pageXmlNode.SelectSingleNode(".."); if (parent != null && (parent.Name == "node" || (parent.Attributes != null && parent.Attributes.GetNamedItem("isDoc") != null))) - _parent = new XmlDocument(parent, true); + _parent = new XmlPublishedContent(parent, true); } } @@ -347,7 +347,7 @@ namespace Umbraco.Web.Models while (iterator.MoveNext()) { _children.Add( - new XmlDocument(((IHasXmlNode)iterator.Current).GetNode(), true) + new XmlPublishedContent(((IHasXmlNode)iterator.Current).GetNode(), true) ); } } diff --git a/src/Umbraco.Web/Mvc/RedirectToUmbracoPageResult.cs b/src/Umbraco.Web/Mvc/RedirectToUmbracoPageResult.cs index 9f74385458..231549cbc6 100644 --- a/src/Umbraco.Web/Mvc/RedirectToUmbracoPageResult.cs +++ b/src/Umbraco.Web/Mvc/RedirectToUmbracoPageResult.cs @@ -11,7 +11,7 @@ namespace Umbraco.Web.Mvc /// public class RedirectToUmbracoPageResult : ActionResult { - private IDocument _document; + private IPublishedContent _publishedContent; private readonly int _pageId; private readonly UmbracoContext _umbracoContext; private string _url; @@ -21,12 +21,12 @@ namespace Umbraco.Web.Mvc { if (!_url.IsNullOrWhiteSpace()) return _url; - if (Document == null) + if (PublishedContent == null) { throw new InvalidOperationException("Cannot redirect, no entity was found for id " + _pageId); } - var result = _umbracoContext.RoutingContext.NiceUrlProvider.GetNiceUrl(Document.Id); + var result = _umbracoContext.RoutingContext.NiceUrlProvider.GetNiceUrl(PublishedContent.Id); if (result != NiceUrlProvider.NullUrl) { _url = result; @@ -38,16 +38,16 @@ namespace Umbraco.Web.Mvc } } - public IDocument Document + public IPublishedContent PublishedContent { get { - if (_document != null) return _document; + if (_publishedContent != null) return _publishedContent; //need to get the URL for the page - _document = PublishedContentStoreResolver.Current.PublishedContentStore.GetDocumentById(_umbracoContext, _pageId); + _publishedContent = PublishedContentStoreResolver.Current.PublishedContentStore.GetDocumentById(_umbracoContext, _pageId); - return _document; + return _publishedContent; } } @@ -63,21 +63,21 @@ namespace Umbraco.Web.Mvc /// /// Creates a new RedirectToUmbracoResult /// - /// - public RedirectToUmbracoPageResult(IDocument document) - : this(document, UmbracoContext.Current) + /// + public RedirectToUmbracoPageResult(IPublishedContent publishedContent) + : this(publishedContent, UmbracoContext.Current) { } /// /// Creates a new RedirectToUmbracoResult /// - /// + /// /// - public RedirectToUmbracoPageResult(IDocument document, UmbracoContext umbracoContext) + public RedirectToUmbracoPageResult(IPublishedContent publishedContent, UmbracoContext umbracoContext) { - _document = document; - _pageId = document.Id; + _publishedContent = publishedContent; + _pageId = publishedContent.Id; _umbracoContext = umbracoContext; } diff --git a/src/Umbraco.Web/Mvc/RenderModel.cs b/src/Umbraco.Web/Mvc/RenderModel.cs index 1fbb2e9c39..2a9506f9d9 100644 --- a/src/Umbraco.Web/Mvc/RenderModel.cs +++ b/src/Umbraco.Web/Mvc/RenderModel.cs @@ -10,9 +10,9 @@ namespace Umbraco.Web.Mvc /// public class RenderModel { - //NOTE: the model isn't just IDocument because in the future we will most likely want to add other properties here, + //NOTE: the model isn't just IPublishedContent because in the future we will most likely want to add other properties here, //or we will want to add extensions. - public IDocument CurrentDocument { get; set; } + public IPublishedContent CurrentPublishedContent { get; set; } } } \ No newline at end of file diff --git a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs index 0dc3b629c9..fdf3e1a781 100644 --- a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs +++ b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs @@ -44,7 +44,7 @@ namespace Umbraco.Web.Mvc var renderModel = new RenderModel() { - CurrentDocument = docRequest.Document + CurrentPublishedContent = docRequest.PublishedContent }; //put essential data into the data tokens, the 'umbraco' key is required to be there for the view engine @@ -183,7 +183,7 @@ namespace Umbraco.Web.Mvc }; //check if there's a custom controller assigned, base on the document type alias. - var controller = _controllerFactory.CreateController(requestContext, documentRequest.Document.DocumentTypeAlias); + var controller = _controllerFactory.CreateController(requestContext, documentRequest.PublishedContent.DocumentTypeAlias); //check if that controller exists @@ -203,7 +203,7 @@ namespace Umbraco.Web.Mvc } else { - LogHelper.Warn("The current Document Type {0} matches a locally declared controller of type {1}. Custom Controllers for Umbraco routing must inherit from '{2}'.", documentRequest.Document.DocumentTypeAlias, controller.GetType().FullName, typeof(RenderMvcController).FullName); + LogHelper.Warn("The current Document Type {0} matches a locally declared controller of type {1}. Custom Controllers for Umbraco routing must inherit from '{2}'.", documentRequest.PublishedContent.DocumentTypeAlias, controller.GetType().FullName, typeof(RenderMvcController).FullName); //exit as we cannnot route to the custom controller, just route to the standard one. return def; } diff --git a/src/Umbraco.Web/Mvc/RenderViewPage.cs b/src/Umbraco.Web/Mvc/RenderViewPage.cs index 8dcf775672..da7cf51595 100644 --- a/src/Umbraco.Web/Mvc/RenderViewPage.cs +++ b/src/Umbraco.Web/Mvc/RenderViewPage.cs @@ -23,7 +23,7 @@ namespace Umbraco.Web.Mvc { ////this.ViewData.Model = Model; //var backingItem = new DynamicBackingItem(Model.CurrentNode); - var dynamicNode = new DynamicDocument(Model.CurrentDocument); + var dynamicNode = new DynamicPublishedContent(Model.CurrentPublishedContent); CurrentPage = dynamicNode.AsDynamic(); } DocumentRequest = (DocumentRequest)ViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-doc-request"); @@ -47,7 +47,7 @@ namespace Umbraco.Web.Mvc internal DocumentRequest DocumentRequest { get; private set; } /// - /// Returns the a DynamicDocument object + /// Returns the a DynamicPublishedContent object /// public dynamic CurrentPage { get; private set; } diff --git a/src/Umbraco.Web/Mvc/SurfaceController.cs b/src/Umbraco.Web/Mvc/SurfaceController.cs index 340294ad54..7c35f0a5c0 100644 --- a/src/Umbraco.Web/Mvc/SurfaceController.cs +++ b/src/Umbraco.Web/Mvc/SurfaceController.cs @@ -73,11 +73,11 @@ namespace Umbraco.Web.Mvc /// /// Redirects to the Umbraco page with the given id /// - /// + /// /// - protected RedirectToUmbracoPageResult RedirectToUmbracoPage(IDocument pageDocument) + protected RedirectToUmbracoPageResult RedirectToUmbracoPage(IPublishedContent pagePublishedContent) { - return new RedirectToUmbracoPageResult(pageDocument, UmbracoContext); + return new RedirectToUmbracoPageResult(pagePublishedContent, UmbracoContext); } /// @@ -101,7 +101,7 @@ namespace Umbraco.Web.Mvc /// /// Gets the current page. /// - protected IDocument CurrentPage + protected IPublishedContent CurrentPage { get { @@ -109,7 +109,7 @@ namespace Umbraco.Web.Mvc throw new InvalidOperationException("Can only use " + typeof(UmbracoPageResult).Name + " in the context of an Http POST when using the BeginUmbracoForm helper"); var routeDef = (RouteDefinition)ControllerContext.RouteData.DataTokens["umbraco-route-def"]; - return routeDef.DocumentRequest.Document; + return routeDef.DocumentRequest.PublishedContent; } } diff --git a/src/Umbraco.Web/Routing/DefaultLastChanceLookup.cs b/src/Umbraco.Web/Routing/DefaultLastChanceLookup.cs index 3268154312..cef71596fe 100644 --- a/src/Umbraco.Web/Routing/DefaultLastChanceLookup.cs +++ b/src/Umbraco.Web/Routing/DefaultLastChanceLookup.cs @@ -38,7 +38,7 @@ namespace Umbraco.Web.Routing /// A value indicating whether an Umbraco document was found and assigned. public bool TrySetDocument(DocumentRequest docRequest) { - docRequest.Document = HandlePageNotFound(docRequest); + docRequest.PublishedContent = HandlePageNotFound(docRequest); return docRequest.HasNode; } @@ -46,12 +46,12 @@ namespace Umbraco.Web.Routing //FIXME: this is temporary and should be obsoleted - IDocument HandlePageNotFound(DocumentRequest docRequest) + IPublishedContent HandlePageNotFound(DocumentRequest docRequest) { LogHelper.Debug("Running for url='{0}'.", () => docRequest.Uri.AbsolutePath); //XmlNode currentPage = null; - IDocument currentPage = null; + IPublishedContent currentPage = null; foreach (var handler in GetNotFoundHandlers()) { diff --git a/src/Umbraco.Web/Routing/DocumentRequest.cs b/src/Umbraco.Web/Routing/DocumentRequest.cs index 249acc48e4..35f747b8bf 100644 --- a/src/Umbraco.Web/Routing/DocumentRequest.cs +++ b/src/Umbraco.Web/Routing/DocumentRequest.cs @@ -37,7 +37,7 @@ namespace Umbraco.Web.Routing /// int _nodeId = 0; - private IDocument _document = null; + private IPublishedContent _publishedContent = null; #region Properties @@ -100,14 +100,14 @@ namespace Umbraco.Web.Routing // TODO: fixme - do we want to have an ordered list of alternate cultures, // to allow for fallbacks when doing dictionnary lookup and such? - public IDocument Document + public IPublishedContent PublishedContent { - get { return _document; } + get { return _publishedContent; } set { - _document = value; + _publishedContent = value; this.Template = null; - _nodeId = _document != null ? _document.Id : 0; + _nodeId = _publishedContent != null ? _publishedContent.Id : 0; } } @@ -132,7 +132,7 @@ namespace Umbraco.Web.Routing { get { - if (this.Document == null) + if (this.PublishedContent == null) throw new InvalidOperationException("DocumentRequest has no document."); return _nodeId; } @@ -143,7 +143,7 @@ namespace Umbraco.Web.Routing /// public bool HasNode { - get { return this.Document != null; } + get { return this.PublishedContent != null; } } /// diff --git a/src/Umbraco.Web/Routing/DocumentRequestBuilder.cs b/src/Umbraco.Web/Routing/DocumentRequestBuilder.cs index 9d2d86844f..333a96bcdd 100644 --- a/src/Umbraco.Web/Routing/DocumentRequestBuilder.cs +++ b/src/Umbraco.Web/Routing/DocumentRequestBuilder.cs @@ -222,7 +222,7 @@ namespace Umbraco.Web.Routing if (i == maxLoop || j == maxLoop) { LogHelper.Debug("{0}Looks like we're running into an infinite loop, abort", () => tracePrefix); - _documentRequest.Document = null; + _documentRequest.PublishedContent = null; } LogHelper.Debug("{0}End", () => tracePrefix); } @@ -239,11 +239,11 @@ namespace Umbraco.Web.Routing { const string tracePrefix = "FollowInternalRedirects: "; - if (_documentRequest.Document == null) + if (_documentRequest.PublishedContent == null) throw new InvalidOperationException("There is no node."); bool redirect = false; - var internalRedirect = _documentRequest.Document.GetPropertyValue("umbracoInternalRedirectId"); + var internalRedirect = _documentRequest.PublishedContent.GetPropertyValue("umbracoInternalRedirectId"); if (!string.IsNullOrWhiteSpace(internalRedirect)) { @@ -271,7 +271,7 @@ namespace Umbraco.Web.Routing _umbracoContext, internalRedirectId); - _documentRequest.Document = node; + _documentRequest.PublishedContent = node; if (node != null) { redirect = true; @@ -295,10 +295,10 @@ namespace Umbraco.Web.Routing { const string tracePrefix = "EnsurePageAccess: "; - if (_documentRequest.Document == null) + if (_documentRequest.PublishedContent == null) throw new InvalidOperationException("There is no node."); - var path = _documentRequest.Document.Path; + var path = _documentRequest.PublishedContent.Path; if (Access.IsProtected(_documentRequest.DocumentId, path)) { @@ -311,7 +311,7 @@ namespace Umbraco.Web.Routing LogHelper.Debug("{0}Not logged in, redirect to login page", () => tracePrefix); var loginPageId = Access.GetLoginPage(path); if (loginPageId != _documentRequest.DocumentId) - _documentRequest.Document = _routingContext.PublishedContentStore.GetDocumentById( + _documentRequest.PublishedContent = _routingContext.PublishedContentStore.GetDocumentById( _umbracoContext, loginPageId); } @@ -320,7 +320,7 @@ namespace Umbraco.Web.Routing LogHelper.Debug("{0}Current member has not access, redirect to error page", () => tracePrefix); var errorPageId = Access.GetErrorPage(path); if (errorPageId != _documentRequest.DocumentId) - _documentRequest.Document = _routingContext.PublishedContentStore.GetDocumentById( + _documentRequest.PublishedContent = _routingContext.PublishedContentStore.GetDocumentById( _umbracoContext, errorPageId); } @@ -345,7 +345,7 @@ namespace Umbraco.Web.Routing const string tracePrefix = "LookupTemplate: "; - if (_documentRequest.Document == null) + if (_documentRequest.PublishedContent == null) throw new InvalidOperationException("There is no node."); //gets item from query string, form, cookie or server vars @@ -357,7 +357,7 @@ namespace Umbraco.Web.Routing // associated with it. //TODO: When we remove the need for a database for templates, then this id should be irrelavent, not sure how were going to do this nicely. - var templateId = _documentRequest.Document.TemplateId; + var templateId = _documentRequest.PublishedContent.TemplateId; LogHelper.Debug("{0}Look for template id={1}", () => tracePrefix, () => templateId); if (templateId > 0) @@ -398,7 +398,7 @@ namespace Umbraco.Web.Routing { if (_documentRequest.HasNode) { - var redirectId = _documentRequest.Document.GetPropertyValue("umbracoRedirect", -1); + var redirectId = _documentRequest.PublishedContent.GetPropertyValue("umbracoRedirect", -1); string redirectUrl = "#"; if (redirectId > 0) diff --git a/src/Umbraco.Web/Routing/LookupByAlias.cs b/src/Umbraco.Web/Routing/LookupByAlias.cs index 07b418498d..83ad35d84e 100644 --- a/src/Umbraco.Web/Routing/LookupByAlias.cs +++ b/src/Umbraco.Web/Routing/LookupByAlias.cs @@ -24,7 +24,7 @@ namespace Umbraco.Web.Routing public bool TrySetDocument(DocumentRequest docRequest) { - IDocument node = null; + IPublishedContent node = null; if (docRequest.Uri.AbsolutePath != "/") // no alias if "/" { @@ -35,7 +35,7 @@ namespace Umbraco.Web.Routing if (node != null) { - docRequest.Document = node; + docRequest.PublishedContent = node; LogHelper.Debug("Path \"{0}\" is an alias for id={1}", () => docRequest.Uri.AbsolutePath, () => docRequest.DocumentId); } } diff --git a/src/Umbraco.Web/Routing/LookupByIdPath.cs b/src/Umbraco.Web/Routing/LookupByIdPath.cs index 5ce5eaa715..59475516fc 100644 --- a/src/Umbraco.Web/Routing/LookupByIdPath.cs +++ b/src/Umbraco.Web/Routing/LookupByIdPath.cs @@ -23,7 +23,7 @@ namespace Umbraco.Web.Routing /// A value indicating whether an Umbraco document was found and assigned. public bool TrySetDocument(DocumentRequest docRequest) { - IDocument node = null; + IPublishedContent node = null; int nodeId = -1; if (docRequest.Uri.AbsolutePath != "/") // no id if "/" @@ -42,7 +42,7 @@ namespace Umbraco.Web.Routing if (node != null) { - docRequest.Document = node; + docRequest.PublishedContent = node; LogHelper.Debug("Found node with id={0}", () => docRequest.DocumentId); } else diff --git a/src/Umbraco.Web/Routing/LookupByNiceUrl.cs b/src/Umbraco.Web/Routing/LookupByNiceUrl.cs index 875a87ca66..13bbd25bb8 100644 --- a/src/Umbraco.Web/Routing/LookupByNiceUrl.cs +++ b/src/Umbraco.Web/Routing/LookupByNiceUrl.cs @@ -38,7 +38,7 @@ namespace Umbraco.Web.Routing /// The document request. /// The route. /// The document node, or null. - protected IDocument LookupDocumentNode(DocumentRequest docreq, string route) + protected IPublishedContent LookupDocumentNode(DocumentRequest docreq, string route) { LogHelper.Debug("Test route \"{0}\"", () => route); @@ -50,7 +50,7 @@ namespace Umbraco.Web.Routing // if a node was found, get it by id and ensure it exists // else clear the cache - IDocument node = null; + IPublishedContent node = null; if (nodeId > 0) { node = docreq.RoutingContext.PublishedContentStore.GetDocumentById( @@ -59,7 +59,7 @@ namespace Umbraco.Web.Routing if (node != null) { - docreq.Document = node; + docreq.PublishedContent = node; LogHelper.Debug("Cache hit, id={0}", () => nodeId); } else @@ -78,7 +78,7 @@ namespace Umbraco.Web.Routing if (node != null) { - docreq.Document = node; + docreq.PublishedContent = node; LogHelper.Debug("Query matches, id={0}", () => docreq.DocumentId); var iscanon = true; diff --git a/src/Umbraco.Web/Routing/LookupByNiceUrlAndTemplate.cs b/src/Umbraco.Web/Routing/LookupByNiceUrlAndTemplate.cs index 08a52cfb15..3d83f72289 100644 --- a/src/Umbraco.Web/Routing/LookupByNiceUrlAndTemplate.cs +++ b/src/Umbraco.Web/Routing/LookupByNiceUrlAndTemplate.cs @@ -24,7 +24,7 @@ namespace Umbraco.Web.Routing /// If successful, also assigns the template. public override bool TrySetDocument(DocumentRequest docRequest) { - IDocument node = null; + IPublishedContent node = null; string path = docRequest.Uri.AbsolutePath; if (docRequest.HasDomain) diff --git a/src/Umbraco.Web/Routing/LookupByPageIdQuery.cs b/src/Umbraco.Web/Routing/LookupByPageIdQuery.cs index cf09dd1799..813644bda5 100644 --- a/src/Umbraco.Web/Routing/LookupByPageIdQuery.cs +++ b/src/Umbraco.Web/Routing/LookupByPageIdQuery.cs @@ -20,7 +20,7 @@ namespace Umbraco.Web.Routing if (doc != null) { - docRequest.Document = doc; + docRequest.PublishedContent = doc; return true; } } diff --git a/src/Umbraco.Web/Routing/LookupByProfile.cs b/src/Umbraco.Web/Routing/LookupByProfile.cs index 10dbfc3601..6056426b1d 100644 --- a/src/Umbraco.Web/Routing/LookupByProfile.cs +++ b/src/Umbraco.Web/Routing/LookupByProfile.cs @@ -24,7 +24,7 @@ namespace Umbraco.Web.Routing /// A value indicating whether an Umbraco document was found and assigned. public override bool TrySetDocument(DocumentRequest docRequest) { - IDocument node = null; + IPublishedContent node = null; bool isProfile = false; var pos = docRequest.Uri.AbsolutePath.LastIndexOf('/'); diff --git a/src/Umbraco.Web/Routing/NiceUrlProvider.cs b/src/Umbraco.Web/Routing/NiceUrlProvider.cs index 38c8ce0133..b11bd4ae26 100644 --- a/src/Umbraco.Web/Routing/NiceUrlProvider.cs +++ b/src/Umbraco.Web/Routing/NiceUrlProvider.cs @@ -302,7 +302,7 @@ namespace Umbraco.Web.Routing return domainAndUris.Select(d => d.Uri); } - void ApplyHideTopLevelNodeFromPath(Core.Models.IDocument node, List pathParts) + void ApplyHideTopLevelNodeFromPath(Core.Models.IPublishedContent node, List pathParts) { // in theory if hideTopLevelNodeFromPath is true, then there should be only once // top-level node, or else domains should be assigned. but for backward compatibility diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index c720b831c8..c88a432d1c 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -325,7 +325,7 @@ - + diff --git a/src/Umbraco.Web/UmbracoHelper.cs b/src/Umbraco.Web/UmbracoHelper.cs index a95bfab955..265f7959d1 100644 --- a/src/Umbraco.Web/UmbracoHelper.cs +++ b/src/Umbraco.Web/UmbracoHelper.cs @@ -33,7 +33,7 @@ namespace Umbraco.Web public class UmbracoHelper { private readonly UmbracoContext _umbracoContext; - private readonly IDocument _currentPage; + private readonly IPublishedContent _currentPage; internal UmbracoHelper(UmbracoContext umbracoContext) { @@ -42,7 +42,7 @@ namespace Umbraco.Web _umbracoContext = umbracoContext; if (_umbracoContext.IsFrontEndUmbracoRequest) { - _currentPage = _umbracoContext.DocumentRequest.Document; + _currentPage = _umbracoContext.DocumentRequest.PublishedContent; } } @@ -162,7 +162,7 @@ namespace Umbraco.Web /// /// /// - public IHtmlString Field(IDocument currentPage, string fieldAlias, + public IHtmlString Field(IPublishedContent currentPage, string fieldAlias, string altFieldAlias = "", string altText = "", string insertBefore = "", string insertAfter = "", bool recursive = false, bool convertLineBreaks = false, bool removeParagraphTags = false, RenderFieldCaseType casing = RenderFieldCaseType.Unchanged, @@ -386,7 +386,7 @@ namespace Umbraco.Web var doc = store.GetDocumentById(UmbracoContext.Current, id); return doc == null ? new DynamicNull() - : new DynamicDocument(doc).AsDynamic(); + : new DynamicPublishedContent(doc).AsDynamic(); } private dynamic DocumentById(string id, IPublishedStore store) @@ -401,7 +401,7 @@ namespace Umbraco.Web { var nodes = ids.Select(eachId => DocumentById(eachId, store)) .Where(x => !TypeHelper.IsTypeAssignableFrom(x)) - .Cast(); + .Cast(); return new DynamicDocumentList(nodes); } @@ -409,7 +409,7 @@ namespace Umbraco.Web { var nodes = ids.Select(eachId => DocumentById(eachId, store)) .Where(x => !TypeHelper.IsTypeAssignableFrom(x)) - .Cast(); + .Cast(); return new DynamicDocumentList(nodes); } diff --git a/src/Umbraco.Web/umbraco.presentation/page.cs b/src/Umbraco.Web/umbraco.presentation/page.cs index 0da5c85c69..994bbce882 100644 --- a/src/Umbraco.Web/umbraco.presentation/page.cs +++ b/src/Umbraco.Web/umbraco.presentation/page.cs @@ -111,10 +111,10 @@ namespace umbraco if (!docreq.HasNode) throw new ArgumentException("Document request has no node.", "docreq"); - populatePageData(docreq.Document.Id, - docreq.Document.Name, docreq.Document.DocumentTypeId, docreq.Document.DocumentTypeAlias, - docreq.Document.WriterName, docreq.Document.CreatorName, docreq.Document.CreateDate, docreq.Document.UpdateDate, - docreq.Document.Path, docreq.Document.Version, docreq.Document.Parent == null ? -1 : docreq.Document.Parent.Id); + populatePageData(docreq.PublishedContent.Id, + docreq.PublishedContent.Name, docreq.PublishedContent.DocumentTypeId, docreq.PublishedContent.DocumentTypeAlias, + docreq.PublishedContent.WriterName, docreq.PublishedContent.CreatorName, docreq.PublishedContent.CreateDate, docreq.PublishedContent.UpdateDate, + docreq.PublishedContent.Path, docreq.PublishedContent.Version, docreq.PublishedContent.Parent == null ? -1 : docreq.PublishedContent.Parent.Id); if (docreq.HasTemplate) { @@ -123,7 +123,7 @@ namespace umbraco _elements["template"] = _template.ToString(); } - PopulateElementData(docreq.Document); + PopulateElementData(docreq.PublishedContent); } @@ -256,7 +256,7 @@ namespace umbraco /// Puts the properties of the node into the elements table /// /// - void PopulateElementData(IDocument node) + void PopulateElementData(IPublishedContent node) { foreach(var p in node.Properties) { diff --git a/src/umbraco.MacroEngines/RazorDynamicNode/DynamicDocumentExtensions.cs b/src/umbraco.MacroEngines/RazorDynamicNode/DynamicDocumentExtensions.cs index 66cd5b8c89..f53758e677 100644 --- a/src/umbraco.MacroEngines/RazorDynamicNode/DynamicDocumentExtensions.cs +++ b/src/umbraco.MacroEngines/RazorDynamicNode/DynamicDocumentExtensions.cs @@ -10,7 +10,7 @@ using umbraco.interfaces; namespace umbraco.MacroEngines.Library { /// - /// Extension methods for converting DynamicDocument to INode + /// Extension methods for converting DynamicPublishedContent to INode /// internal static class DynamicDocumentExtensions { @@ -20,20 +20,20 @@ namespace umbraco.MacroEngines.Library return new PropertyResult(prop.Alias, prop.Value.ToString(), prop.Version); } - internal static INode ConvertToNode(this DynamicDocument doc) + internal static INode ConvertToNode(this DynamicPublishedContent doc) { var node = new ConvertedNode(doc); return node; } /// - /// Internal custom INode class used for conversions from DynamicDocument + /// Internal custom INode class used for conversions from DynamicPublishedContent /// private class ConvertedNode : INode { - private readonly DynamicDocument _doc; + private readonly DynamicPublishedContent _doc; - public ConvertedNode(DynamicDocument doc) + public ConvertedNode(DynamicPublishedContent doc) { _doc = doc; template = doc.TemplateId; diff --git a/src/umbraco.MacroEngines/RazorDynamicNode/DynamicNode.cs b/src/umbraco.MacroEngines/RazorDynamicNode/DynamicNode.cs index e4b98b571d..0b8446739c 100644 --- a/src/umbraco.MacroEngines/RazorDynamicNode/DynamicNode.cs +++ b/src/umbraco.MacroEngines/RazorDynamicNode/DynamicNode.cs @@ -543,7 +543,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 DynamicDocument uses until we create our new data access layer. + //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 staticMapping = UmbracoSettings.RazorDataTypeModelStaticMapping.FirstOrDefault(mapping =>