using System; using System.Collections.Generic; using System.Text; using System.Collections; using System.IO; namespace Persistence { public class Root { [Storable] public int[] i = new int[] { 3, 4, 5, 6 }; [Storable] public string s; [Storable] public ArrayList intArray = new ArrayList(new int[] { 1, 2, 3 }); [Storable] public List intList = new List(new int[] { 321, 312, 321 }); [Storable] public Custom c; [Storable] public List selfReferences; [Storable] public double[,] multiDimArray = new double[,] { { 1, 2, 3 }, { 3, 4, 5 } }; [Storable] public bool boolean = true; [Storable] public DateTime dateTime = new DateTime(); [Storable] public KeyValuePair kvp = new KeyValuePair("test key", 123); [Storable] public Dictionary dict = new Dictionary(); } public class Custom { [Storable] public int i; [Storable] public Root r; [Storable] public string name = "Serial"; } public class NewSerializationTest { public static void Main() { Root r = new Root(); r.selfReferences = new List(); r.selfReferences.Add(r); r.selfReferences.Add(r); r.c = new Custom(); r.c.r = r; r.dict.Add("one", 1); r.dict.Add("two", 2); r.dict.Add("three", 3); Serializer s = new Serializer(r); Persistence.XmlFormatter xmlFormatter = new Persistence.XmlFormatter(); StreamWriter writer = new StreamWriter("test.xml"); foreach (ISerializationToken token in s) { string line = xmlFormatter.Format(token); writer.Write(line); Console.Out.Write(line); } writer.Close(); XmlParser parser = new XmlParser(new StreamReader("test.xml")); DeSerializer deSerializer = new DeSerializer(); object o = deSerializer.DeSerialize(parser); Console.Out.WriteLine(Util.AutoFormat(o, true)); Console.In.ReadLine(); } } }