Advertisement
Guest User

Untitled

a guest
Feb 15th, 2012
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.76 KB | None | 0 0
  1. module main;
  2.  
  3. import orange.core._;
  4. import orange.serialization._;
  5. import orange.serialization.archives._;
  6.  
  7. class Foo
  8. {
  9.     int a;
  10.     Foo refme;
  11. }
  12.  
  13. void main ()
  14. {
  15.     auto foo = new Foo; // create something to serialize
  16.     foo.a = 3; // change the default value of "a"
  17.     auto foo2 = new Foo; // create something to serialize
  18.     foo2.a = 42;
  19.     foo.refme = foo2;
  20.  
  21.     auto archive = new XmlArchive!(char); // create an XML archive
  22.     auto serializer = new Serializer(archive); // create the serializer
  23.  
  24.     serializer.serialize(foo); // serialize "foo"
  25.  
  26.     // deserialize the serialized data as an instance of "Foo"
  27.     auto f = serializer.deserialize!(Foo)(archive.untypedData);
  28.  
  29.     // verify that the deserialized value is equal to the original value
  30.     assert(f.a == foo.a);
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement