下面是測試代碼:
1.[STAThread]
2.static void Main()
3.{
4. //插入測試
5. WriteTest();
6.
7. //讀取測試
8. ReadTest();
9.}
10.
11.private static void WriteTest()
12.{
13. Person person = new Person();
14. person.Name = "snoopy";
15. person.Age = 5;
16. person.Sex = "male";
17.
18. Hand lefthand = new Hand();
19. lefthand.Name = "左手";
20.
21. Hand righthand = new Hand();
22. righthand.Name = "右手";
23.
24. Head head = new Head();
25. head.Name = "大笨腦袋";
26.
27. person.LeftHand = lefthand;
28. person.RightHand = righthand;
29. person.Head = head;
30.
31. MiniORM.OrmWriter write = new OrmWriter();
32. write.Write(person);
33.}
34.
35.private static void ReadTest()
36.{
37. MiniORM.OrmReader reader = new OrmReader();
38. Person person = (Person)reader.Read(new Person(), 1);
39.
40.
41. Console.WriteLine("person.Name:" + person.Name);
42. Console.WriteLine("person.Age:" + person.Age);
43. Console.WriteLine("person.Sex:" + person.Sex);
44. Console.WriteLine("LeftHand.Name:" + person.LeftHand.Name);
45. Console.WriteLine("RightHand.Name:" + person.RightHand.Name);
46. Console.WriteLine("Head.Name:" + person.Head.Name);
47.
48. Console.Read();
49.}
ReadTest的測試結果如圖:
好了,各位,你可以使用這個調試代碼來試試了。。。