static void TestPListParse() { PListDict dict = new PListDict(); dict.FromXmlFile("新建文本文档.txt"); string result = dict.ToXmlString(); Console.WriteLine(result); }
static void TestPList() { PListDict ht = new PListDict(); ht["user"] = new PListDict("lgx"); ht["password"] = new PListDict("123456"); decimal gender = (decimal)25.6; double g2 = 33.4; float g3 = 45.2f; int age = 18; bool istrue = true; bool isfalse = false; ht["gender"] = new PListDict(gender); ht["g2"] = new PListDict(g2); ht["g3"] = new PListDict(g3); PListDict ht2 = new PListDict(); ht2["age"] = new PListDict(age); ht2["istrue"] = new PListDict(istrue); ht2["isfalse"] = new PListDict(isfalse); ht["ht2"] = ht2; PListArray pa = new PListArray(); PListArray array = new PListArray(); array.Add(new PListDict(1)); array.Add(new PListDict("234")); array.Add(new PListDict(23.4)); array.Add(new PListDict(DateTime.Now)); PListDict ht3 = new PListDict(); ht3["age"] = new PListDict(age); ht3["istrue"] = new PListDict(istrue); ht3["isfalse"] = new PListDict(isfalse); PListDict ht4 = new PListDict(); ht4["ht3"] = ht3; array.Add(ht4); ht["array"] = array; string result = ht.ToXmlString(); Console.WriteLine(result); PListDict node = new PListDict(); node.FromXmlString(result); string nodestr = node.ToJson(); string arrayJson = array.ToJson(); Console.WriteLine(nodestr); JToken jsonObj = (JToken)JsonConvert.DeserializeObject(nodestr); JToken jsonArray = (JToken)JsonConvert.DeserializeObject(arrayJson); IPListNode node2 = new PListArray(); node2 = node2.FromJson(nodestr); string str3 = node2.ToJson(); Console.WriteLine(str3); }