//xml转为为nodes private void NodesFromXML(CHMNodeList nodes, System.Xml.XmlElement RootElement) { foreach (System.Xml.XmlNode node in RootElement.ChildNodes) { if (node.Name == "Node") { System.Xml.XmlElement element = (System.Xml.XmlElement)node; CHMNode NewNode = new CHMNode(); NewNode.Name = element.GetAttribute("Name"); NewNode.Local = element.GetAttribute("Local"); NewNode.ImageNo = element.GetAttribute("ImageNumber"); NewNode.KeyWords = element.GetAttribute("KeyWords"); nodes.Add(NewNode); foreach (System.Xml.XmlNode node2 in element.ChildNodes) { if (node2.Name == "Items") { NodesFromXML(NewNode.Nodes, (System.Xml.XmlElement)node2); } } } } }
/// <summary> /// 节点位于list的索引 /// </summary> /// <param name="node"></param> /// <returns></returns> public int IndexOf(CHMNode node) { return(this.List.IndexOf(node)); }
/// <summary> /// 是否包含该节点 /// </summary> /// <param name="node"></param> /// <returns></returns> public bool Contains(CHMNode node) { return(this.List.Contains(node)); }
/// <summary> /// 移除第一个匹配的节点 /// </summary> /// <param name="node">待移除的节点</param> public void Remove(CHMNode node) { this.List.Remove(node); }
/// <summary> /// 插入节点 /// </summary> /// <param name="index">位置</param> /// <param name="node">待插入的节点</param> public void Insert(int index, CHMNode node) { this.List.Insert(index, node); }
/// <summary> /// 添加节点 /// </summary> /// <param name="node">待添加的节点</param> /// <returns></returns> public int Add(CHMNode node) { return(this.List.Add(node)); }