当前位置: 首页>>代码示例>>C#>>正文


C# IContentLoader.GetChildren方法代码示例

本文整理汇总了C#中IContentLoader.GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C# IContentLoader.GetChildren方法的具体用法?C# IContentLoader.GetChildren怎么用?C# IContentLoader.GetChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IContentLoader的用法示例。


在下文中一共展示了IContentLoader.GetChildren方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateMenuItem

 private static MenuItem CreateMenuItem(PageData page, ContentReference currentContentLink, List<ContentReference> pagePath, IContentLoader contentLoader, Func<IEnumerable<PageData>, IEnumerable<PageData>> filter)
 {
     var menuItem = new MenuItem(page)
         {
             Selected = page.ContentLink.CompareToIgnoreWorkID(currentContentLink) ||
                        pagePath.Contains(page.ContentLink),
             HasChildren =
                 new Lazy<bool>(() => filter(contentLoader.GetChildren<PageData>(page.ContentLink)).Any())
         };
     return menuItem;
 }
开发者ID:VladimirLevchuk,项目名称:Alloy.AndAsync,代码行数:11,代码来源:HtmlHelpers.cs

示例2: CreateMenuItem

 private static MenuItem CreateMenuItem(PageData page, ContentReference currentContentLink, ContentReference rootLink, IContentLoader contentLoader, Func<IEnumerable<PageData>, IEnumerable<PageData>> filter)
 {
     var menuItem = new MenuItem
     {
         Page = page,
         Selected = page.ContentLink.CompareToIgnoreWorkID(currentContentLink),
         HasChildren = new Lazy<bool>(() => filter(contentLoader.GetChildren<PageData>(page.ContentLink)).Any()),
         HasSelectedChildPage = new Lazy<bool>(() => HasSelectedChildPage(rootLink, currentContentLink, page))
     };
     return menuItem;
 }
开发者ID:dnasir,项目名称:EPi.Extensions,代码行数:11,代码来源:HtmlHelperExtensions.cs

示例3: GetSiblings

 public static IEnumerable<PageData> GetSiblings(this PageData pageData, IContentLoader contentLoader)
 {
     var filter = new FilterContentForVisitor();
     return contentLoader.GetChildren<PageData>(pageData.ParentLink).Where(page => !filter.ShouldFilter(page));
 }
开发者ID:adrian18hd,项目名称:Quicksilver,代码行数:5,代码来源:ContentExtensions.cs

示例4: RenderMainNavigation

        public static void RenderMainNavigation(this HtmlHelper html, PageReference rootLink = null,
            ContentReference contentLink = null,
            bool includeRoot = true, IContentLoader contentLoader = null)
        {
            contentLink = contentLink ?? html.ViewContext.RequestContext.GetContentLink();
            rootLink = rootLink ?? ContentReference.StartPage;

            var writer = html.ViewContext.Writer;

            // top level
            writer.WriteLine("<nav class=\"navbar navbar-inverse\">");
            writer.WriteLine("<ul class=\"nav navbar-nav\">");
            if (includeRoot)
            {
                if (rootLink.CompareToIgnoreWorkID(contentLink))
                {
                    writer.WriteLine("<li class=\"active\">");
                }
                else
                {
                    writer.WriteLine("<li>");
                }

                writer.WriteLine(html.PageLink(rootLink).ToHtmlString());
                writer.WriteLine("</li>");
            }

            // hämta ut alla barn från start

            contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();

            var topLevelPages = contentLoader.GetChildren<PageData>(rootLink);
            topLevelPages = FilterForVisitor.Filter(topLevelPages).OfType<PageData>().Where(x => x.VisibleInMenu);

            var currentBranch = contentLoader.GetAncestors(contentLink).Select(x => x.ContentLink).ToList();
            currentBranch.Add(contentLink);
            //skriv ut dom
            foreach (var topLevelPage in topLevelPages)
            {
                if (currentBranch.Any(x => x.CompareToIgnoreWorkID(topLevelPage.ContentLink)))
                {
                    writer.WriteLine("<li class=\"active\">");
                }
                else
                {
                    writer.WriteLine("<li>");
                }

                writer.WriteLine(html.PageLink(topLevelPage).ToHtmlString());
                writer.WriteLine("</li>");
            }
            //Close top level
            writer.WriteLine("</ul");
            writer.WriteLine("</nav>");
        }
开发者ID:Siipikeisari,项目名称:fruitcorp,代码行数:55,代码来源:NavigationHelpers.cs

示例5: RenderSubNavigationLevel

        private static void RenderSubNavigationLevel(HtmlHelper helper, ContentReference levelRootLink,
            IEnumerable<ContentReference> path, IContentLoader contentLoader)
        {
            var children = contentLoader.GetChildren<PageData>(levelRootLink);
            children = FilterForVisitor.Filter(children).OfType<PageData>().Where(x => x.VisibleInMenu);

            if (!children.Any())
            {
                return;
            }

            var writer = helper.ViewContext.Writer;

            writer.WriteLine("<ul class=\"nav\">");

            var indexedChildren = children.Select((page, index) => new
            {
                index,
                page

            }).ToList();

            foreach (var levelItem in indexedChildren)
            {
                var page = levelItem.page;
                var partOfCurrentBranch = path.Any(x => x.CompareToIgnoreWorkID(levelItem.page.ContentLink));

                if (partOfCurrentBranch)
                {
                    writer.WriteLine("<li class=\"active\">");
                }
                else
                {

                    writer.WriteLine("<li>");
                }

                writer.WriteLine(helper.PageLink(page).ToHtmlString());

                if (partOfCurrentBranch)
                {
                    RenderSubNavigationLevel(helper, page.ContentLink, path, contentLoader);
                }

                writer.WriteLine("</li>");
            }

            writer.WriteLine("</ul>");
        }
开发者ID:Siipikeisari,项目名称:fruitcorp,代码行数:49,代码来源:NavigationHelpers.cs

示例6: RenderSubNavigationLevel

    private static void RenderSubNavigationLevel(
          HtmlHelper helper,
          ContentReference levelRootLink,
          IEnumerable<ContentReference> path,
          IContentLoader contentLoader)
    {
      //Retrieve and filter the pages on the current level
      var children = contentLoader.GetChildren<PageData>(levelRootLink);
      children = FilterForVisitor.Filter(children)
                                 .OfType<PageData>()
                                 .Where(x => x.VisibleInMenu);

      if (!children.Any())
      {
        //There's nothing to render on this level so we abort
        //in order not to write an empty ul element.
        return;
      }

      var writer = helper.ViewContext.Writer;

      //Open list element for the current level
      writer.WriteLine("<ul class=\"nav\">");

      //Project to an anonymous class in order to know
      //the index of each page in the collection when
      //iterating over it.
      var indexedChildren = children
        .Select((page, index) => new { index, page })
        .ToList();

      foreach (var levelItem in indexedChildren)
      {
        var page = levelItem.page;
        var partOfCurrentBranch = path.Any(x =>
          x.CompareToIgnoreWorkID(levelItem.page.ContentLink));

        if (partOfCurrentBranch)
        {
          //We highlight pages that are part of the current branch,
          //including the currently viewed page.
          writer.WriteLine("<li class=\"active\">");
        }
        else
        {
          writer.WriteLine("<li>");
        }
        writer.WriteLine(helper.PageLink(page).ToHtmlString());

        if (partOfCurrentBranch)
        {
          //The page is part of the current pages branch, 
          //so we render a level below it 
          RenderSubNavigationLevel(
            helper,
            page.ContentLink,
            path,
            contentLoader);
        }
        writer.WriteLine("</li>");
      }

      //Close list element
      writer.WriteLine("</ul>");
    }
开发者ID:role7504,项目名称:episerver_book_code_examples,代码行数:65,代码来源:NavigationHelpers.cs

示例7: RenderMainNavigation

    public static void RenderMainNavigation(
      this HtmlHelper html,
      PageReference rootLink = null,
      ContentReference contentLink = null,
      bool includeRoot = true,
      IContentLoader contentLoader = null)
    {
      contentLink = contentLink ??
        html.ViewContext.RequestContext.GetContentLink();
      rootLink = rootLink ??
        ContentReference.StartPage;

      var writer = html.ViewContext.Writer;

      //Top level elements
      writer.WriteLine("<nav class=\"navbar navbar-inverse\">");
      writer.WriteLine("<ul class=\"nav navbar-nav\">");

      if (includeRoot)
      {
        //Link to the root page
        if (rootLink.CompareToIgnoreWorkID(contentLink))
        {
          writer.WriteLine("<li class=\"active\">");
        }
        else
        {
          writer.WriteLine("<li>");
        }
        writer.WriteLine(
          html.PageLink(rootLink).ToHtmlString());
        writer.WriteLine("</li>");
      }

      //Retrieve and filter the root pages children
      contentLoader = contentLoader ??
        ServiceLocator.Current.GetInstance<IContentLoader>();
      var topLevelPages = contentLoader
        .GetChildren<PageData>(rootLink);
      topLevelPages = FilterForVisitor.Filter(topLevelPages)
        .OfType<PageData>()
        .Where(x => x.VisibleInMenu);

      //Retrieve the "path" from the current page up to the
      //root page in the content tree in order to check if
      //a link should be highlighted.
      var currentBranch = contentLoader.GetAncestors(contentLink)
        .Select(x => x.ContentLink)
        .ToList();
      currentBranch.Add(contentLink);

      //Link to the root pages children
      foreach (var topLevelPage in topLevelPages)
      {
        if (currentBranch.Any(x =>
          x.CompareToIgnoreWorkID(topLevelPage.ContentLink)))
        {
          writer.WriteLine("<li class=\"active\">");
        }
        else
        {
          writer.WriteLine("<li>");
        }
        writer.WriteLine(html.PageLink(topLevelPage).ToHtmlString());
        writer.WriteLine("</li>");
      }

      //Close top level element
      writer.WriteLine("</ul>");
      writer.WriteLine("</nav>");
    }
开发者ID:role7504,项目名称:episerver_book_code_examples,代码行数:71,代码来源:NavigationHelpers.cs


注:本文中的IContentLoader.GetChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。