U4-6674 - Refactor ToContentSet entirely

Created by Stephan 05 Jun 2015, 16:00:45 Updated by Stephan 08 Jan 2018, 09:12:07

Relates to: U4-7038

Up to v7 we have a heavy plumbing in IPublishedContent only to support the "content set" legacy feature and IsOdd() or IsFirst() accessors when iterating published content. We should remove it entirely, and ToContentSet() should return a ContentSetItem which would have the IsOdd() etc accessors and a Content accessors giving access to the underlying IPublishedContent - that way, it's more explicit, and the entire plumbing can be massively simplified.

Comments

Stephan 22 Jun 2016, 08:21:34

Definitively NOT backward compatible.

Previously: ''foreach (var item in items.ToContentSet())'' where ''item'' was an IPublishedContent which had the ''Index'', ''IsFirst'' etc methods & properties.

Now: ''foreach (var item in items.ToIndexedArray())'' where ''item'' is an IndexedArrayItem which has all the ''Index'', ''IsFirst'' etc methods & properties plus a ''Content'' property returning the IPublishedContent.

In the first case, one could write code such as

foreach (var item in items.ToContentSet()) { <div class="@(item.IsFirst()?"first":"")">@item.Name

}

Now that code becomes:

foreach (var item in items.ToIndexedArray()) { <div class="@(item.IsFirst()?"first":"")">@item.Content.Name

}

Having the extra .Content thing is a minor inconvenience, and it helps separating the enumeration concerns from the IPublishedContent, which in turns means that the IPublishedContent implementation can be greatly simplified. Which is a good thing.


Stephan 08 Jan 2018, 09:12:02

done in 8, closing


Priority: Normal

Type: Feature (request)

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: False

Fix Submitted:

Affected versions:

Due in version: 8.0.0

Sprint:

Story Points:

Cycle: