public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
CreateTree();
comboBox1.SelectedIndex = 0;
}
public void CreateTree()
{
try
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("../../Project_GeoWorkSpaces.xml");
XmlNode xNode = xmlDoc.SelectSingleNode("dotfuscator");
XmlElement xElement = (XmlElement)xNode;
label2.Text = xElement.GetAttribute("version");
TreeNode node = new TreeNode();
AddTreeNode(xNode, node);
}
catch
{
//异常排除
}
}
public void AddTreeNode(XmlNode xmlNode, TreeNode treeNode)
{
XmlElement tempElement;
TreeNode tempTreeNode;
if (xmlNode.ChildNodes.Count > 0)
{
foreach (XmlNode node in xmlNode.ChildNodes)
{
switch (node.Name)
{
case "input":
tempElement = (XmlElement)node.SelectSingleNode("asmlist/inputassembly/file");
comboBox1.Items.Add(tempElement.GetAttribute("dir"));
break;
case "renaming":
case "excludelist":
AddTreeNode(node, treeNode);
break;
case "namespace":
tempElement = (XmlElement)node;
treeNode = new TreeNode("命名空间:" + tempElement.GetAttribute("name"));
AddTreeNode(node, treeNode);
this.treeView1.Nodes.Add(treeNode);
break;
case "type":
tempElement = (XmlElement)node;
string[] str = tempElement.GetAttribute("name").Split('.');
tempTreeNode = new TreeNode("类名:" + str[1]);
AddTreeNode(node, tempTreeNode);
treeNode.Nodes.Add(tempTreeNode);
break;
case "method":
tempElement = (XmlElement)node;
tempTreeNode = new TreeNode("方法:" + tempElement.GetAttribute("name"));
treeNode.Nodes.Add(tempTreeNode);
break;
case "propertymember":
tempElement = (XmlElement)node;
tempTreeNode = new TreeNode("属性:" + tempElement.GetAttribute("name"));
treeNode.Nodes.Add(tempTreeNode);
break;
case "field":
tempElement = (XmlElement)node;
tempTreeNode = new TreeNode("字段:" + tempElement.GetAttribute("name"));
treeNode.Nodes.Add(tempTreeNode);
break;
}
}
}
}