示例#1
0
        /// <summary>
        /// 新建一个数节点
        /// </summary>
        public TreeStaticNode <T> GetNode(T val)
        {
            TreeStaticNode <T> _treenode = this.Find(t => t.id.CompareTo(val));

            if (_treenode != null)
            {
                return(_treenode);
            }
            else
            {
                return(new TreeStaticNode <T>());
            }
        }
示例#2
0
        public TreeStaticNode <T> NewNode <V>(V entity) where V : class
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            TreeStaticNode <T> node = new TreeStaticNode <T>();

            PropertyInfo[] properties = typeof(V).GetProperties();

            properties.ToList().ForEach(property =>
            {
                object propertyValue = property.GetValue(entity, null);

                switch (property.Name.Trim().ToLower())
                {
                case "id": node.id = propertyValue.Convert <T>(); break;

                case "name": node.name = propertyValue.Convert(""); break;

                case "pid": node.pId = propertyValue.Convert(""); break;

                case "hide": node.isHidden = propertyValue.Convert(false); break;

                case "leaf": node.isParent = !propertyValue.Convert(false); break;

                case "icon": node.iconSkin = propertyValue.Convert(""); break;

                default:
                    break;
                }
            });

            return(node);
        }