- Timestamp:
- 03/09/09 17:25:27 (16 years ago)
- Location:
- branches/New Persistence Exploration/Persistence/Persistence
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/New Persistence Exploration/Persistence/Persistence/NewSerializationTest.cs
r1318 r1320 42 42 } 43 43 44 public class Manager { 45 46 private DateTime lastLoadTime; 47 [Storable] 48 private DateTime lastLoadTimePersistence { 49 get { return lastLoadTime; } 50 set { this.lastLoadTime = DateTime.Now; } 51 } 52 [Storable] 53 private Nullable<double> dbl = null; 54 } 55 44 56 public class NewSerializationTest { 45 public static void Main() { 57 58 public static void Test1() { 46 59 Root r = new Root(); 47 60 r.selfReferences = new List<Root>(); … … 65 78 DeSerializer deSerializer = new DeSerializer(); 66 79 object o = deSerializer.DeSerialize(parser); 80 Console.Out.WriteLine(Util.AutoFormat(o, true)); 81 } 82 83 public static void Test2() { 84 Manager m = new Manager(); 85 Serializer s = new Serializer(m); 86 Persistence.XmlFormatter xmlFormatter = new Persistence.XmlFormatter(); 87 StreamWriter writer = new StreamWriter("test2.xml"); 88 foreach (ISerializationToken token in s) { 89 string line = xmlFormatter.Format(token); 90 writer.Write(line); 91 Console.Out.Write(line); 92 } 93 writer.Close(); 94 XmlParser parser = new XmlParser(new StreamReader("test2.xml")); 95 DeSerializer deSerializer = new DeSerializer(); 96 object o = deSerializer.DeSerialize(parser); 67 97 Console.Out.WriteLine(Util.AutoFormat(o, true)); 98 } 99 100 public static void Main() { 101 //Test1(); 102 Test2(); 68 103 Console.In.ReadLine(); 69 104 } -
branches/New Persistence Exploration/Persistence/Persistence/XmlFormatter.cs
r1280 r1320 31 31 string result = 32 32 String.Format("{0}<COMPOSITE name=\"{1}\" type=\"{2}\" id=\"{3}\">\n", 33 this.Prefix, beginToken.Accessor.Name, beginToken.Accessor. Type, beginToken.Id);33 this.Prefix, beginToken.Accessor.Name, beginToken.Accessor.Get().GetType(), beginToken.Id); 34 34 this.depth += 1; 35 35 return result; … … 45 45 PrimitiveToken dataToken = (PrimitiveToken)token; 46 46 return String.Format("{0}<PRIMITIVE name=\"{1}\" type=\"{2}\">{3}</PRIMITIVE>\n", 47 this.Prefix, dataToken.accessor.Name, dataToken.accessor. Type, dataToken.Data);47 this.Prefix, dataToken.accessor.Name, dataToken.accessor.Get().GetType(), dataToken.Data); 48 48 } 49 49
Note: See TracChangeset
for help on using the changeset viewer.