Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module main;
- import orange.core._;
- import orange.serialization._;
- import orange.serialization.archives._;
- class Foo
- {
- int a;
- Foo refme;
- }
- void main ()
- {
- auto foo = new Foo; // create something to serialize
- foo.a = 3; // change the default value of "a"
- auto foo2 = new Foo; // create something to serialize
- foo2.a = 42;
- foo.refme = foo2;
- auto archive = new XmlArchive!(char); // create an XML archive
- auto serializer = new Serializer(archive); // create the serializer
- serializer.serialize(foo); // serialize "foo"
- // deserialize the serialized data as an instance of "Foo"
- auto f = serializer.deserialize!(Foo)(archive.untypedData);
- // verify that the deserialized value is equal to the original value
- assert(f.a == foo.a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement