Last change
on this file since 1264 was
1264,
checked in by epitzer, 15 years ago
|
Full serialization from object tree to XML. No de-serialization yet. (#506)
|
File size:
1.1 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Text;
|
---|
4 | using System.Collections;
|
---|
5 |
|
---|
6 | namespace Persistence {
|
---|
7 |
|
---|
8 | public class Root {
|
---|
9 |
|
---|
10 | [Storable]
|
---|
11 | public int[] i = new int[] { 3, 4, 5, 6 };
|
---|
12 | [Storable]
|
---|
13 | public string s;
|
---|
14 | [Storable]
|
---|
15 | public ArrayList intArray = new ArrayList(new int[] { 1, 2, 3 });
|
---|
16 | [Storable]
|
---|
17 | public Custom c;
|
---|
18 |
|
---|
19 | }
|
---|
20 |
|
---|
21 | public class Custom {
|
---|
22 | [Storable]
|
---|
23 | public int i;
|
---|
24 | [Storable]
|
---|
25 | public Root r;
|
---|
26 | [Storable]
|
---|
27 | public string name = "Serial";
|
---|
28 | }
|
---|
29 |
|
---|
30 | public class NewSerializationTest {
|
---|
31 | public static void Main() {
|
---|
32 | Root r = new Root();
|
---|
33 | r.c = new Custom();
|
---|
34 | r.c.r = r;
|
---|
35 | IPrimitiveSerializer[] serializers = {
|
---|
36 | new String2XMLSerializer(),
|
---|
37 | new Int2XMLSerializer()};
|
---|
38 | Serializer s = new Serializer(r, serializers);
|
---|
39 | Persistence.XmlFormatter xmlFormatter = new Persistence.XmlFormatter();
|
---|
40 | foreach (ISerializationToken token in s) {
|
---|
41 | Console.Write(xmlFormatter.Format(token));
|
---|
42 | }
|
---|
43 | Console.In.ReadLine();
|
---|
44 | }
|
---|
45 | }
|
---|
46 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.