source: trunk/TestCase/SimpleTestCase/SerializeTest.ab@ 475

Last change on this file since 475 was 475, checked in by dai, 16 years ago

XmlSerializer.Deserializeメソッドを実装(仮実装なため、数値メンバのシリアライズのみに留まっている)。
XmlNode.LastChildメソッドを追加。
XmlNode.NextSiblingメソッドを追加。
XmlNode.PreviouseSiblingメソッドを追加。

File size: 1.4 KB
Line 
1Namespace SerializeTest
2
3
4Class Foo
5Public
6 a As Long
7 b As Long
8 c As Long
9 d As Long
10
11 Sub Foo()
12 a=100
13 b=200
14 c=300
15 d=400
16 End Sub
17End Class
18
19Sub TestMain()
20 ' 一時ディレクトリを取得
21 Dim tempDir = GetExclusiveTempDirPath( "SerializeTest" )
22
23 ' fooインスタンスを生成
24 Dim foo = New Foo
25 foo.a = 500
26 foo.b = 600
27 foo.c = 700
28 foo.d = 800
29
30
31 '----------------------------------------------------------------
32 ' シリアライズ
33 '----------------------------------------------------------------
34
35 ' 保存先のファイルを開いて、
36 Dim fooXmlFilePath = tempDir + "\foo.xml"
37 Dim ofs = New System.IO.FileStream( fooXmlFilePath, System.IO.FileMode.Create )
38
39 ' シリアライズして、
40 Dim serializer = New System.Xml.Serialization.XmlSerializer( foo.GetType() )
41 serializer.Serialize( ofs, foo )
42
43 ' 閉じる。
44 ofs.Close()
45
46
47 '----------------------------------------------------------------
48 ' デシリアライズ
49 '----------------------------------------------------------------
50
51 ' 読込先のファイルを開いて
52 Dim ifs = New System.IO.FileStream( fooXmlFilePath, System.IO.FileMode.Open )
53
54 ' デシリアライズして
55 Dim fooDash = serializer.Deserialize( ifs ) As Foo
56
57 ' 閉じる
58 ifs.Close()
59
60 UnitTest( "XmlSerializer", foo.a = fooDash.a and foo.b = fooDash.b and foo.c = fooDash.c and foo.d = fooDash.d )
61End Sub
62
63
64End Namespace
65
66SerializeTest.TestMain()
Note: See TracBrowser for help on using the repository browser.