Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/19/09 14:02:35 (15 years ago)
Author:
epitzer
Message:

Add serializer class information to type cache. (#506)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/New Persistence Exploration/Persistence/Persistence/Core/Serializer.cs

    r1361 r1362  
    55
    66namespace HeuristicLab.Persistence.Core {
     7
     8  public struct TypeMapping {
     9    public readonly int Id;
     10    public readonly string TypeName;
     11    public readonly string Serializer;   
     12    public TypeMapping(int id, string typeName, string serializer) {
     13      Id = id;
     14      TypeName = typeName;
     15      Serializer = serializer;
     16    }
     17    public Dictionary<string, object> GetDict() {
     18      return new Dictionary<string, object> {
     19        {"id", Id},
     20        {"typeName", TypeName},
     21        {"serializer", Serializer}};                                           
     22    }
     23  }
    724
    825  public class Serializer : IEnumerable<ISerializationToken> {
     
    1431    private readonly Configuration configuration;
    1532
    16     public Dictionary<string, int> TypeCache {
     33    public List<TypeMapping> TypeCache {
    1734      get {       
    18         Dictionary<string, int> result = new Dictionary<string, int>();
    19         foreach ( var pair in typeCache )
    20           result.Add(pair.Key.AssemblyQualifiedName, pair.Value);
     35        List<TypeMapping> result = new List<TypeMapping>();
     36        foreach (var pair in typeCache) {
     37          string serializer = null;
     38          IFormatter f = configuration.GetFormatter(pair.Key);
     39          if (f != null) {
     40            serializer = f.GetType().AssemblyQualifiedName;
     41          } else {
     42            IDecomposer d = configuration.GetDecomposer(pair.Key);
     43            if (d != null)
     44              serializer = d.GetType().AssemblyQualifiedName;
     45          }
     46          result.Add(new TypeMapping(pair.Value, pair.Key.AssemblyQualifiedName, serializer));
     47        }
    2148        return result;                                     
    2249      }
Note: See TracChangeset for help on using the changeset viewer.