public static void TestList() { string FILE_NAME="student.xml"; List<Student> students=new List<Student>(); students.Add(new Student("ken", 27, Sex.Male)); students.Add(new Student("tony", 27, Sex.Male)); students.Add(new Student("albert", 37, Sex.Male)); KZXML<List<Student>> xml=new KZXML<List<Student>>(); try { xml.Save(students, FILE_NAME); List<Student> t=xml.Load(FILE_NAME); foreach(Student s in t) { Debug.Log(s); } } catch(Exception) { Debug.LogError("Failed to Save or Load!"); } }
public static void TestSingle() { string FILE_NAME="student.xml"; Student s=new Student("ken", 27, Sex.Male); KZXML<Student> xml=new KZXML<Student>(); try { xml.Save(s, FILE_NAME); } catch(Exception) { Debug.LogError("Failed to Save!"); } Student t=null; try { t=xml.Load(FILE_NAME); } catch(Exception) { Debug.LogError("Failed to Load!"); } if(t==null || t.ToString() != "ken (27), Male") { Debug.LogError(t); } else { Debug.Log("OK!"); } }
public static void TestString() { string input="hello, <§A¦nworld"; KZXML<string> xml=new KZXML<string>(); try { xml.Save(input, "hello.xml"); } catch(Exception) { Debug.LogError("Failed to Save!"); } }