using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace VOL.Entity.DomainModels
{
class PubFunction
{
}
public class XmlHelp
{
///
/// 编写报文内容
///
/// 父节点名称
/// xmldocument类型
/// 要插入的子节点名称
/// 子节点内容
public void CreateChild(XmlElement Father, XmlDocument doc, string NodeName, object text)
{
XmlElement ChildName = doc.CreateElement("" + NodeName + "");
if (text != null)
{
ChildName.InnerText = text.ToString();
}
Father.AppendChild(ChildName);
}
}
public class el_cascader {
public string id { get; set; }
public string name { get; set; }
public string pid { get; set; }
public List children { get; set; }
public el_cascader() {
children = new List();
}
public el_cascader(string id, string pid, string name) {
this.id = id;
this.pid = pid;
this.name = name;
}
public void addnode(el_cascader newnode) {
if (children == null || children.Count == 0) return;
if (id == newnode.pid)
{
if (!children.Exists(x => x.id == newnode.id))
{
children.Add(newnode);
}
}
else {
foreach (var item in children) {
item.addnode(newnode);
}
}
}
}
public class el_cascader_tree {
private List treelist{ get; set; }
public el_cascader_tree() {
treelist = new List();
}
public void addnode(string id, string pid, string name) {
var newnode = new el_cascader(id, pid, name);
if (string.IsNullOrWhiteSpace(pid))
{
if (!treelist.Exists(x => x.id == newnode.id))
{
treelist.Add(newnode);
}
}
else {
foreach (var item in treelist) {
item.addnode(newnode);
}
}
}
public List gettreelist() {
return treelist;
}
}
}