Skip to content

Commit

Permalink
Added filter to orphan error message in SiteMapBuilder so it only dis…
Browse files Browse the repository at this point in the history
…plays the orphans and not the descendant nodes of the orphans that matched.
  • Loading branch information
NightOwl888 committed Sep 12, 2013
1 parent 1961fe7 commit dd50ad0
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ public ISiteMapNode BuildSiteMap(ISiteMap siteMap, ISiteMapNode rootNode)

if (orphans.Count() > 0)
{
// We have orphaned nodes - throw an exception.
var names = String.Join(Environment.NewLine + Environment.NewLine, orphans.Select(x => String.Format(Resources.Messages.SiteMapNodeFormatWithParentKey, x.ParentKey, x.Node.Controller, x.Node.Action, x.Node.Area, x.Node.Url, x.Node.Key, x.SourceName)).ToArray());
// We have orphaned nodes - filter to remove the matching descendants of the mismatched keys.
var mismatched = from parent in orphans
where !(from child in orphans
select child.Node.Key)
.Contains(parent.ParentKey)
select parent;

var names = String.Join(Environment.NewLine + Environment.NewLine, mismatched.Select(x => String.Format(Resources.Messages.SiteMapNodeFormatWithParentKey, x.ParentKey, x.Node.Controller, x.Node.Action, x.Node.Area, x.Node.Url, x.Node.Key, x.SourceName)).ToArray());
throw new MvcSiteMapException(String.Format(Resources.Messages.SiteMapBuilderOrphanedNodes, siteMapCacheKey, names));
}

Expand Down

0 comments on commit dd50ad0

Please sign in to comment.