Skip to content

Commit

Permalink
Fix Structure items order by Alias (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseMarcenaro authored and KevinJump committed Sep 23, 2019
1 parent 250cddd commit a33faa0
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,18 @@ protected virtual void SerializeExtraProperties(XElement node, TObject item, Pro
protected XElement SerializeStructure(TObject item)
{
var node = new XElement("Structure");

foreach (var allowedType in item.AllowedContentTypes.OrderBy(x => x.Alias))
List<KeyValuePair<string, string>> items = new List<KeyValuePair<string, string>>();

foreach (var allowedType in item.AllowedContentTypes)
{
var allowedItem = FindItem(allowedType.Id.Value);
if (allowedItem != null)
{
node.Add(new XElement(ItemType, new XAttribute("Key", allowedItem.Key.ToString()), allowedItem.Alias));
items.Add(new KeyValuePair<string, string>(allowedItem.Key.ToString(), allowedItem.Alias));
}
}

if (items.Count > 0)
node.Add(items.OrderBy(x => x.Value).Select(x => new XElement(ItemType, new XAttribute("Key", x.Key), x.Value)).ToArray());
return node;
}

Expand Down

0 comments on commit a33faa0

Please sign in to comment.