From fe9f5b224aeaeaab4bd92ce87b92f9c61ebaa4f0 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Sat, 2 Mar 2013 03:34:37 +0600 Subject: [PATCH] Fixing really strange merge issues! --- .../EnumerableExtensionsTests.cs | 65 ++++++- .../Models/DynamicPublishedContent.cs | 163 +----------------- src/Umbraco.Web/Models/XmlPublishedContent.cs | 23 --- src/Umbraco.Web/PublishedContentExtensions.cs | 23 --- 4 files changed, 66 insertions(+), 208 deletions(-) diff --git a/src/Umbraco.Tests/EnumerableExtensionsTests.cs b/src/Umbraco.Tests/EnumerableExtensionsTests.cs index 64f0c6a381..23ff7f8aca 100644 --- a/src/Umbraco.Tests/EnumerableExtensionsTests.cs +++ b/src/Umbraco.Tests/EnumerableExtensionsTests.cs @@ -10,7 +10,70 @@ namespace Umbraco.Tests [TestFixture] public class EnumerableExtensionsTests { - [Test] + + [Test] + public void Flatten_List() + { + var hierarchy = new TestItem() + { + Children = new List() + { + new TestItem() + { + Children = new List() + { + new TestItem() + { + Children = new List() + { + new TestItem() + { + Children = new List() + } + } + } + } + }, + new TestItem() + { + Children = new List() + { + new TestItem() + { + Children = new List() + { + new TestItem() + { + Children = new List() + } + } + }, + new TestItem() + { + Children = new List() + { + new TestItem() + { + Children = new List() + } + } + } + } + }, + } + }; + + var flattened = hierarchy.Children.FlattenList(x => x.Children); + + Assert.AreEqual(8, flattened); + } + + private class TestItem + { + public IEnumerable Children { get; set; } + } + + [Test] public void InGroupsOf_ReturnsAllElements() { var integers = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; diff --git a/src/Umbraco.Web/Models/DynamicPublishedContent.cs b/src/Umbraco.Web/Models/DynamicPublishedContent.cs index a4a43f7b22..0f066c3ee1 100644 --- a/src/Umbraco.Web/Models/DynamicPublishedContent.cs +++ b/src/Umbraco.Web/Models/DynamicPublishedContent.cs @@ -74,167 +74,8 @@ namespace Umbraco.Web.Models _ownersCollection = value; } } - } - - private IEnumerable _ownersCollection; - - /// - /// Need to get/set the owner collection when an item is returned from the result set of a query - /// - /// - /// Based on this issue here: http://issues.umbraco.org/issue/U4-1797 - /// - IEnumerable IOwnerCollectionAware.OwnersCollection - { - get - { - var publishedContentBase = PublishedContent as IOwnerCollectionAware; - if (publishedContentBase != null) - { - return publishedContentBase.OwnersCollection; - } - - //if the owners collection is null, we'll default to it's siblings - if (_ownersCollection == null) - { - //get the root docs if parent is null - _ownersCollection = this.Siblings(); - } - return _ownersCollection; - } - set - { - var publishedContentBase = PublishedContent as IOwnerCollectionAware; - if (publishedContentBase != null) - { - publishedContentBase.OwnersCollection = value; - } - else - { - _ownersCollection = value; - } - } - } - - private IEnumerable _ownersCollection; - - /// - /// Need to get/set the owner collection when an item is returned from the result set of a query - /// - /// - /// Based on this issue here: http://issues.umbraco.org/issue/U4-1797 - /// - IEnumerable IOwnerCollectionAware.OwnersCollection - { - get - { - var publishedContentBase = PublishedContent as IOwnerCollectionAware; - if (publishedContentBase != null) - { - return publishedContentBase.OwnersCollection; - } - - //if the owners collection is null, we'll default to it's siblings - if (_ownersCollection == null) - { - //get the root docs if parent is null - _ownersCollection = this.Siblings(); - } - return _ownersCollection; - } - set - { - var publishedContentBase = PublishedContent as IOwnerCollectionAware; - if (publishedContentBase != null) - { - publishedContentBase.OwnersCollection = value; - } - else - { - _ownersCollection = value; - } - } - } - - private IEnumerable _ownersCollection; - - /// - /// Need to get/set the owner collection when an item is returned from the result set of a query - /// - /// - /// Based on this issue here: http://issues.umbraco.org/issue/U4-1797 - /// - IEnumerable IOwnerCollectionAware.OwnersCollection - { - get - { - var publishedContentBase = PublishedContent as IOwnerCollectionAware; - if (publishedContentBase != null) - { - return publishedContentBase.OwnersCollection; - } - - //if the owners collection is null, we'll default to it's siblings - if (_ownersCollection == null) - { - //get the root docs if parent is null - _ownersCollection = this.Siblings(); - } - return _ownersCollection; - } - set - { - var publishedContentBase = PublishedContent as IOwnerCollectionAware; - if (publishedContentBase != null) - { - publishedContentBase.OwnersCollection = value; - } - else - { - _ownersCollection = value; - } - } - } - - private IEnumerable _ownersCollection; - - /// - /// Need to get/set the owner collection when an item is returned from the result set of a query - /// - /// - /// Based on this issue here: http://issues.umbraco.org/issue/U4-1797 - /// - IEnumerable IOwnerCollectionAware.OwnersCollection - { - get - { - var publishedContentBase = PublishedContent as IOwnerCollectionAware; - if (publishedContentBase != null) - { - return publishedContentBase.OwnersCollection; - } - - //if the owners collection is null, we'll default to it's siblings - if (_ownersCollection == null) - { - //get the root docs if parent is null - _ownersCollection = this.Siblings(); - } - return _ownersCollection; - } - set - { - var publishedContentBase = PublishedContent as IOwnerCollectionAware; - if (publishedContentBase != null) - { - publishedContentBase.OwnersCollection = value; - } - else - { - _ownersCollection = value; - } - } - } + } + public dynamic AsDynamic() { diff --git a/src/Umbraco.Web/Models/XmlPublishedContent.cs b/src/Umbraco.Web/Models/XmlPublishedContent.cs index 299d3bf083..867fc8c144 100644 --- a/src/Umbraco.Web/Models/XmlPublishedContent.cs +++ b/src/Umbraco.Web/Models/XmlPublishedContent.cs @@ -44,29 +44,6 @@ namespace Umbraco.Web.Models Initialize(); } - private IEnumerable _ownersCollection; - - /// - /// Need to get/set the owner collection when an item is returned from the result set of a query - /// - /// - /// Based on this issue here: http://issues.umbraco.org/issue/U4-1797 - /// - IEnumerable IOwnerCollectionAware.OwnersCollection - { - get - { - //if the owners collection is null, we'll default to it's siblings - if (_ownersCollection == null) - { - //get the root docs if parent is null - _ownersCollection = this.Siblings(); - } - return _ownersCollection; - } - set { _ownersCollection = value; } - } - private bool _initialized = false; private readonly ICollection _children = new Collection(); private IPublishedContent _parent = null; diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index db475b2509..3c76260a63 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -782,29 +782,6 @@ namespace Umbraco.Web return test(content) ? new HtmlString(valueIfTrue) : new HtmlString(valueIfFalse); } - /// - /// Return the owners collection of the current content item. - /// - /// - /// - /// - /// If the content item is of type PublishedContentBase we will have a property called OwnersCollection which will - /// be the collection of a resultant set (i.e. from a where clause, a call to Children(), etc...) otherwise it will - /// be the item's siblings. All relates to this issue: http://issues.umbraco.org/issue/U4-1797 - /// - private static IEnumerable GetOwnersList(this IPublishedContent content) - { - //Here we need to type check, we need to see if we have a real OwnersCollection list based on the result set - // of a query, otherwise we can only lookup among the item's siblings. All related to this issue here: - // http://issues.umbraco.org/issue/U4-1797 - - var publishedContentBase = content as IOwnerCollectionAware; - var ownersList = publishedContentBase != null - ? publishedContentBase.OwnersCollection - : content.Siblings(); - return ownersList; - } - #endregion #region Ancestors