public void RunTestCode(string basepath) { string xml = basepath + "test/testxml/home_config.xml"; XmlDocument doc = new XmlDocument(); doc.Load(xml); XmlNode root = doc.LastChild; HomeConfig data = new HomeConfig(); if (!data.Parse(root)) { Console.WriteLine("解析{0}失败", xml); return; } //写入bytes文件 byte[] b = GenericBuilder.GenericsEncode(data); FileStream fs = File.Create("home_config.bytes"); fs.Write(b, 0, b.Length); fs.Close(); //dump内容 HomeConfig d = GenericParser.GenericsDecode <HomeConfig>(b); string s = GenericDump.Dump(d); fs = File.Create("home_config.txt"); StreamWriter sw = new StreamWriter(fs); sw.WriteLine(s); sw.Close(); fs.Close(); }
public void RunTestCode(string basepath) { string xml = basepath + "test/testxml/community_answer_library.xml"; XmlDocument doc = new XmlDocument(); doc.Load(xml); XmlNode root = doc.LastChild; AnswerLibrary data = new AnswerLibrary(); if (!data.Parse(root)) { Console.WriteLine("解析{0}失败", xml); return; } //写入bytes文件 byte[] b = GenericBuilder.GenericsEncode(data); FileStream fs = File.Create("community_answer_library.bytes"); fs.Write(b, 0, b.Length); fs.Close(); //dump内容 AnswerLibrary d = GenericParser.GenericsDecode <AnswerLibrary>(b); string s = GenericDump.Dump(d); fs = File.Create("community_answer_library.txt"); StreamWriter sw = new StreamWriter(fs); sw.WriteLine(s); sw.Close(); fs.Close(); }