Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/06/09 17:18:22 (16 years ago)
Author:
epitzer
Message:

Configurable de-serializers. (#506)

Location:
branches/New Persistence Exploration/Persistence/Persistence
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/New Persistence Exploration/Persistence/Persistence/NewSerializationTest.cs

    r1274 r1278  
    4949      writer.Close();
    5050      XmlParser parser = new XmlParser(new StreamReader("test.xml"));
    51       DeSerializer deSerializer = new DeSerializer();     
     51      DeSerializer deSerializer = new DeSerializer(
     52        new IPrimitiveSerializer[] { new Int2XMLSerializer(), new String2XMLSerializer() },
     53        new ICustomSerializer[] { new ArraySerializer(), new EnumerableSerializer() });
    5254      object o = deSerializer.DeSerialize(parser);
    5355      Console.Out.WriteLine(Util.AutoFormat(o, true));
  • branches/New Persistence Exploration/Persistence/Persistence/PersistenceManager.cs

    r1276 r1278  
    270270    private List<ICustomSerializer> customSerializers;
    271271
    272     public DeSerializer() {
     272    public DeSerializer(
     273        IEnumerable<IPrimitiveSerializer> primitiveSerializers,
     274        IEnumerable<ICustomSerializer> customSerializers) {
    273275      id2obj = new Dictionary<int, object>();
    274276      compositeStack = new Stack<IAccessibleObject>();
     
    280282      handlers.Add(typeof(Null), new Handler(NullHandler));
    281283      // TODO: make this configurable
    282       primitiveSerializers = new Dictionary<Type, IPrimitiveSerializer>();
    283       primitiveSerializers.Add(typeof(int), new Int2XMLSerializer());
    284       primitiveSerializers.Add(typeof(string), new String2XMLSerializer());
    285       customSerializers = new List<ICustomSerializer>();
    286       customSerializers.Add(new ArraySerializer());
    287       customSerializers.Add(new EnumerableSerializer());     
     284      this.primitiveSerializers = new Dictionary<Type, IPrimitiveSerializer>();
     285      foreach (IPrimitiveSerializer ps in primitiveSerializers) {
     286        this.primitiveSerializers.Add(ps.Type, ps);
     287      }
     288      this.customSerializers = new List<ICustomSerializer>(customSerializers);
     289     
    288290    }
    289291    public object DeSerialize(IEnumerable<IParseToken> tokens) {
Note: See TracChangeset for help on using the changeset viewer.