Exemple #1
0
        private IEnumerable <PageModel> GetChildren(Data.Page p, int depth)
        {
            var firstLevel = new[] { p }.ToList();
            var levels = EnumerableEx.Generate(new { pages = firstLevel, depth = Math.Max(4, depth) }, x => x.depth >= 0 && x.pages.Any(),
                                               x => new { pages = PagesService.GetChildPages(x.pages).ToList(), depth = x.depth - 1 },
                                               x => x.pages)
                         .ToList();

            return(MergeChildPages(p, levels.Skip(1)));
        }
Exemple #2
0
        private IEnumerable <PageModel> MergeChildPages(Data.Page parent, IEnumerable <List <Data.Page> > levels)
        {
            var prefix = parent.Url + "/";

            return(from c in levels.FirstOrDefault().EmptyIfNull()
                   where c.Url.StartsWith(prefix)
                   orderby c.SortOrder
                   select new PageModel {
                Page = c,
                ChildPages = MergeChildPages(c, levels.Skip(1))
            });
        }