Changeset 1312
- Timestamp:
- 03/09/09 12:41:36 (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
r1281 r1312 21 21 [Storable] 22 22 public List<Root> selfReferences; 23 24 23 } 25 24 … … 43 42 IPrimitiveSerializer[] serializers = { 44 43 new String2XMLSerializer(), 45 new Int2XMLSerializer()}; 44 new Int2XMLSerializer(), 45 new Double2XmlSerializer()}; 46 46 Serializer s = new Serializer(r, serializers); 47 47 Persistence.XmlFormatter xmlFormatter = new Persistence.XmlFormatter(); … … 55 55 XmlParser parser = new XmlParser(new StreamReader("test.xml")); 56 56 DeSerializer deSerializer = new DeSerializer( 57 new IPrimitiveSerializer[] { new Int2XMLSerializer(), new String2XMLSerializer() }, 58 new ICustomSerializer[] { new ArraySerializer(), new EnumerableSerializer() }); 57 new IPrimitiveSerializer[] { 58 new Int2XMLSerializer(), 59 new String2XMLSerializer(), 60 new Double2XmlSerializer(), 61 }, 62 new ICustomSerializer[] { 63 new ArraySerializer(), 64 new EnumerableSerializer() }); 59 65 object o = deSerializer.DeSerialize(parser); 60 66 Console.Out.WriteLine(Util.AutoFormat(o, true)); -
branches/New Persistence Exploration/Persistence/Persistence/PrimitiveSerializers.cs
r1280 r1312 1 1 using System; 2 2 using System.Text; 3 using System.Globalization; 3 4 namespace Persistence { 4 5 … … 26 27 } 27 28 } 28 29 29 public class Int2XMLSerializer : IPrimitiveSerializer { 30 30 public Type Type { get { return typeof(int); } } … … 36 36 } 37 37 } 38 public class Double2XmlSerializer : IPrimitiveSerializer { 39 public Type Type { get { return typeof(double); } } 40 public object Serialize(object o) { 41 return ((double)o).ToString("r", CultureInfo.InvariantCulture); 42 } 43 public object DeSerialize(object o) { 44 return double.Parse((string)o, CultureInfo.InvariantCulture); 45 } 46 } 38 47 }
Note: See TracChangeset
for help on using the changeset viewer.