Fixing really strange merge issues!
This commit is contained in:
@@ -10,7 +10,70 @@ namespace Umbraco.Tests
|
||||
[TestFixture]
|
||||
public class EnumerableExtensionsTests
|
||||
{
|
||||
[Test]
|
||||
|
||||
[Test]
|
||||
public void Flatten_List()
|
||||
{
|
||||
var hierarchy = new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
{
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
{
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
{
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
{
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
{
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
}
|
||||
}
|
||||
},
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
{
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var flattened = hierarchy.Children.FlattenList(x => x.Children);
|
||||
|
||||
Assert.AreEqual(8, flattened);
|
||||
}
|
||||
|
||||
private class TestItem
|
||||
{
|
||||
public IEnumerable<TestItem> Children { get; set; }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InGroupsOf_ReturnsAllElements()
|
||||
{
|
||||
var integers = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||
|
||||
@@ -74,167 +74,8 @@ namespace Umbraco.Web.Models
|
||||
_ownersCollection = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<IPublishedContent> _ownersCollection;
|
||||
|
||||
/// <summary>
|
||||
/// Need to get/set the owner collection when an item is returned from the result set of a query
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Based on this issue here: http://issues.umbraco.org/issue/U4-1797
|
||||
/// </remarks>
|
||||
IEnumerable<IPublishedContent> IOwnerCollectionAware<IPublishedContent>.OwnersCollection
|
||||
{
|
||||
get
|
||||
{
|
||||
var publishedContentBase = PublishedContent as IOwnerCollectionAware<IPublishedContent>;
|
||||
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<IPublishedContent>;
|
||||
if (publishedContentBase != null)
|
||||
{
|
||||
publishedContentBase.OwnersCollection = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ownersCollection = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<IPublishedContent> _ownersCollection;
|
||||
|
||||
/// <summary>
|
||||
/// Need to get/set the owner collection when an item is returned from the result set of a query
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Based on this issue here: http://issues.umbraco.org/issue/U4-1797
|
||||
/// </remarks>
|
||||
IEnumerable<IPublishedContent> IOwnerCollectionAware<IPublishedContent>.OwnersCollection
|
||||
{
|
||||
get
|
||||
{
|
||||
var publishedContentBase = PublishedContent as IOwnerCollectionAware<IPublishedContent>;
|
||||
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<IPublishedContent>;
|
||||
if (publishedContentBase != null)
|
||||
{
|
||||
publishedContentBase.OwnersCollection = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ownersCollection = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<IPublishedContent> _ownersCollection;
|
||||
|
||||
/// <summary>
|
||||
/// Need to get/set the owner collection when an item is returned from the result set of a query
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Based on this issue here: http://issues.umbraco.org/issue/U4-1797
|
||||
/// </remarks>
|
||||
IEnumerable<IPublishedContent> IOwnerCollectionAware<IPublishedContent>.OwnersCollection
|
||||
{
|
||||
get
|
||||
{
|
||||
var publishedContentBase = PublishedContent as IOwnerCollectionAware<IPublishedContent>;
|
||||
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<IPublishedContent>;
|
||||
if (publishedContentBase != null)
|
||||
{
|
||||
publishedContentBase.OwnersCollection = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ownersCollection = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<IPublishedContent> _ownersCollection;
|
||||
|
||||
/// <summary>
|
||||
/// Need to get/set the owner collection when an item is returned from the result set of a query
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Based on this issue here: http://issues.umbraco.org/issue/U4-1797
|
||||
/// </remarks>
|
||||
IEnumerable<IPublishedContent> IOwnerCollectionAware<IPublishedContent>.OwnersCollection
|
||||
{
|
||||
get
|
||||
{
|
||||
var publishedContentBase = PublishedContent as IOwnerCollectionAware<IPublishedContent>;
|
||||
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<IPublishedContent>;
|
||||
if (publishedContentBase != null)
|
||||
{
|
||||
publishedContentBase.OwnersCollection = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ownersCollection = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public dynamic AsDynamic()
|
||||
{
|
||||
|
||||
@@ -44,29 +44,6 @@ namespace Umbraco.Web.Models
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private IEnumerable<IPublishedContent> _ownersCollection;
|
||||
|
||||
/// <summary>
|
||||
/// Need to get/set the owner collection when an item is returned from the result set of a query
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Based on this issue here: http://issues.umbraco.org/issue/U4-1797
|
||||
/// </remarks>
|
||||
IEnumerable<IPublishedContent> IOwnerCollectionAware<IPublishedContent>.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<IPublishedContent> _children = new Collection<IPublishedContent>();
|
||||
private IPublishedContent _parent = null;
|
||||
|
||||
@@ -782,29 +782,6 @@ namespace Umbraco.Web
|
||||
return test(content) ? new HtmlString(valueIfTrue) : new HtmlString(valueIfFalse);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the owners collection of the current content item.
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// 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
|
||||
/// </remarks>
|
||||
private static IEnumerable<IPublishedContent> 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<IPublishedContent>;
|
||||
var ownersList = publishedContentBase != null
|
||||
? publishedContentBase.OwnersCollection
|
||||
: content.Siblings();
|
||||
return ownersList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Ancestors
|
||||
|
||||
Reference in New Issue
Block a user