Exemplo n.º 1
0
    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!");
        }
    }
Exemplo n.º 2
0
    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!");
        }
    }