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


C# NodeCollection.FirstOrDefault方法代码示例

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


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

示例1: BuildAreasLevel

        private static NodeCollection BuildAreasLevel()
        {
            string path = HttpContext.Current.Server.MapPath(ExamplesModel.ExamplesRoot);
            DirectoryInfo root = new DirectoryInfo(path);
            DirectoryInfo[] folders = root.GetDirectories();
            folders = ExamplesModel.SortFolders(root, folders);

            NodeCollection nodes = new NodeCollection(false);

            var staticIcons = new StaticNodeIcon(path);

            foreach (DirectoryInfo folder in folders)
            {
                if ((folder.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden ||
                    excludeList.Contains(folder.Name) || folder.Name.StartsWith("_"))
                {
                    continue;
                }

                ExampleConfig cfg = new ExampleConfig(folder.FullName + "\\config.xml");

                string iconCls = string.IsNullOrEmpty(cfg.IconCls) ? "" : cfg.IconCls;
                Node node = null;
                var index = folder.Name.IndexOf('_');

                if (cfg.MainGroup || index < 0)
                {
                    node = new Node();
                    node.NodeID = BaseControl.GenerateID();
                    node.Text = folder.Name.Replace("_", " ");

                    nodes.Add(node);

                    if (String.IsNullOrWhiteSpace(iconCls)) {
                        staticIcons.TryGetIconCLS(out iconCls, folder.Name);
                    }

                    node.IconCls = iconCls;
                    if (ExamplesModel.IsNew(folder.FullName))
                    {
                        node.CustomAttributes.Add(new ConfigItem("isNew", "true", ParameterMode.Raw));
                    }
                }
                else
                {
                    string otherIconCls;
                    var mainGroupName = folder.Name.Substring(0, index);
                    node = nodes.FirstOrDefault(n => n.Text == mainGroupName);

                    if (node == null)
                    {
                        node = new Node();
                        node.NodeID = BaseControl.GenerateID();
                        node.Text = mainGroupName;
                        nodes.Add(node);
                    }

                    if (staticIcons.TryGetIconCLS(out otherIconCls, mainGroupName))
                    {
                        node.IconCls = otherIconCls;
                    }

                    if (ExamplesModel.IsNew(folder.FullName) && !node.CustomAttributes.Contains("isNew"))
                    {
                        node.CustomAttributes.Add(new ConfigItem("isNew", "true", ParameterMode.Raw));
                    }

                    var groupNode = new Node();
                    var subGroupNodeName = folder.Name.Substring(index + 1);

                    groupNode.NodeID = BaseControl.GenerateID();
                    groupNode.Text = subGroupNodeName.Replace("_", " ");

                    if (iconCls.IsNotEmpty())
                    {
                        groupNode.IconCls = iconCls;
                    }
                    else if (staticIcons.TryGetIconCLS(out otherIconCls, mainGroupName, subGroupNodeName))
                    {
                        groupNode.IconCls = otherIconCls;
                    }

                    if (ExamplesModel.IsNew(folder.FullName) && !groupNode.CustomAttributes.Contains("isNew"))
                    {
                        groupNode.CustomAttributes.Add(new ConfigItem("isNew", "true", ParameterMode.Raw));
                    }

                    node.Children.Add(groupNode);
                    node = groupNode;
                }

                ExamplesModel.BuildViewsLevel(folder, node);
            }

            return nodes;
        }
开发者ID:extnet,项目名称:Ext.NET.Examples.MVC,代码行数:96,代码来源:ExamplesModel.cs


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