Changeset 475 for trunk/TestCase/SimpleTestCase
- Timestamp:
- Mar 13, 2008, 9:44:51 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/TestCase/SimpleTestCase/SerializeTest.ab
r465 r475 1 1 Namespace SerializeTest 2 2 3 3 4 Class Foo 5 Public 4 6 a As Long 5 7 b As Long 6 8 c As Long 7 9 d As Long 8 Public 10 9 11 Sub Foo() 10 12 a=100 … … 21 23 ' fooインスタンスを生成 22 24 Dim foo = New Foo 25 foo.a = 500 26 foo.b = 600 27 foo.c = 700 28 foo.d = 800 23 29 24 30 … … 29 35 ' 保存先のファイルを開いて、 30 36 Dim fooXmlFilePath = tempDir + "\foo.xml" 31 Dim fs = New System.IO.FileStream( fooXmlFilePath, System.IO.FileMode.Create )37 Dim ofs = New System.IO.FileStream( fooXmlFilePath, System.IO.FileMode.Create ) 32 38 33 39 ' シリアライズして、 34 40 Dim serializer = New System.Xml.Serialization.XmlSerializer( foo.GetType() ) 35 serializer.Serialize( fs, foo )41 serializer.Serialize( ofs, foo ) 36 42 37 43 ' 閉じる。 38 fs.Close()44 ofs.Close() 39 45 40 46 … … 43 49 '---------------------------------------------------------------- 44 50 45 ' 読み込んでみる。 46 Dim doc = New System.Xml.XmlDocument 47 doc.Load( tempDir + "\foo.xml" ) 48 System.Diagnostics.Debug.WriteLine( doc.OuterXml ) 51 ' 読込先のファイルを開いて 52 Dim ifs = New System.IO.FileStream( fooXmlFilePath, System.IO.FileMode.Open ) 49 53 50 ' TODO: デシリアライズは未完成( ̄□ ̄;) 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 ) 51 61 End Sub 52 62
Note:
See TracChangeset
for help on using the changeset viewer.