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


C# Tree.GetChildren方法代码示例

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


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

示例1: Equals

        private static bool Equals(Tree thisTree, Tree otherTree) {
            if (thisTree == null && otherTree == null) return true;
            if (thisTree == null || otherTree == null) return false;
            if (thisTree.Title != otherTree.Title) return false;

            IEnumerator theseChildren = thisTree.GetChildren().GetEnumerator();
            foreach (Tree treeChild in otherTree.GetChildren()) {
                if (!theseChildren.MoveNext()) return false;
                if (!Equals(theseChildren.Current, treeChild)) return false;
            }
            return !theseChildren.MoveNext();
        }
开发者ID:GibSral,项目名称:fitsharp,代码行数:12,代码来源:ParseTree.cs

示例2: ToParseString

 public static string ToParseString(Tree theTree) {
     var result = new StringBuilder();
     if (theTree.Title != null) result.Append(theTree.Title);
     int childCount = 0;
     foreach (Tree child in theTree.GetChildren()) {
         if (childCount == 0) result.Append("<ul>");
         result.AppendFormat("<li>{0}</li>", ToParseString(child));
         childCount++;
     }
     if (childCount > 0) result.Append("</ul>");
     return result.ToString();
 }
开发者ID:GibSral,项目名称:fitsharp,代码行数:12,代码来源:ParseTree.cs

示例3: addLocationMenu

        private static void addLocationMenu( StringBuilder sb, MvcContext ctx ) {

            sb.Append( "<ul class=\"dropdown-menu\" id=\"locationBoards\">" );

            ForumBoardService service = new ForumBoardService();
            Tree<ForumBoard> tree = new Tree<ForumBoard>( service.GetBoardAll( ctx.app.Id, ctx.viewer.IsLogin ) );
            List<ForumBoard> categories = tree.GetRoots();

            foreach (ForumBoard category in categories) {
                sb.AppendFormat( "<li class=\"forum_location_category\">{0}</li>", category.Name );
                sb.Append( "<li class=\"forum_location_forums\">" );
                List<ForumBoard> children = tree.GetChildren( category.Id );
                foreach (ForumBoard board in children) {
                    sb.AppendFormat( "<a href=\"{0}\">{1}</a> ", alink.ToAppData( board ), board.Name );
                }
                sb.Append( "</li>" );
            }
            sb.Append( "</ul>" );
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:19,代码来源:ForumLocationUtil.cs

示例4: testTreeData

        public void testTreeData()
        {
            List<Node> nodes = getNodesAll();

            Tree<Node> tree = new Tree<Node>( nodes );

            // GetById
            INode node = tree.GetById( 13 );
            Assert.IsNotNull( node );
            Assert.AreEqual( "node13", node.Name );

            INode nullNode = tree.GetById( 9999 );
            Assert.IsNull( nullNode );

            // GetParent
            INode parent = tree.GetParent( node.Id );
            Assert.IsNotNull( parent );
            Assert.AreEqual( 5, parent.Id );

            // GetDepth
            Assert.AreEqual( 0, tree.GetDepth( 2 ) );
            Assert.AreEqual( 1, tree.GetDepth( 7 ) );
            Assert.AreEqual( 2, tree.GetDepth( 13 ) );
            Assert.AreEqual( 2, tree.GetDepth( 14 ) );

            // GetPath
            List<Node> path = tree.GetPath( 13 );
            Assert.AreEqual( 3, path.Count );

            Assert.AreEqual( 1, path[0].Id );
            Assert.AreEqual( 5, path[1].Id );
            Assert.AreEqual( 13, path[2].Id );

            // GetChildren
            Assert.AreEqual( 0, tree.GetChildren( 4 ).Count );
            Assert.AreEqual( 0, tree.GetChildren( 7 ).Count );

            List<Node> children = tree.GetChildren( 5 );
            Assert.AreEqual( 3, children.Count );
            Assert.AreEqual( 13, children[0].Id );
            Assert.AreEqual( 14, children[1].Id );
            Assert.AreEqual( 15, children[2].Id );

            // GetRoots
            List<Node> roots = tree.GetRoots();
            Assert.AreEqual( 3, roots.Count );
            Assert.AreEqual( 1, roots[0].Id );
            Assert.AreEqual( 2, roots[1].Id );
            Assert.AreEqual( 3, roots[2].Id );
        }
开发者ID:bae2014,项目名称:wojilu,代码行数:50,代码来源:TreeTest.cs

示例5: Equals

 private bool Equals(Parse theParse, Tree theTree)
 {
     if (theParse == null && theTree == null) return true;
     if (theParse == null || theTree == null) return false;
     if (GetTitle(theParse) != theTree.Title) return false;
     Parse parseChild = Root(theParse).Parts;
     foreach (Tree treeChild in theTree.GetChildren()) {
         if (!Equals(parseChild, treeChild)) return false;
         parseChild = parseChild.More;
     }
     return (parseChild == null);
 }
开发者ID:vaibhavsapre,项目名称:fitsharp,代码行数:12,代码来源:ParseTree.cs


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