Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/06/10 16:59:13 (13 years ago)
Author:
epitzer
Message:

Properly copy serializers when initializing global configuration. (#1136)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/DeSerializer.cs

    r4068 r4175  
    8585    private readonly Stack<Midwife> parentStack;
    8686    private readonly Dictionary<int, Type> typeIds;
     87    private Dictionary<Type, object> serializerInstances;
    8788
    8889    /// <summary>
     
    9899      typeIds = new Dictionary<int, Type>();
    99100      serializerMapping = new Dictionary<Type, object>();
     101      serializerInstances = new Dictionary<Type, object>();
    100102      foreach (var typeMapping in typeCache) {
    101103        AddTypeInfo(typeMapping);
    102104      }
    103105    }
    104 
    105     private Dictionary<Type, object> serializerInstances = new Dictionary<Type, object>();
    106106
    107107    /// <summary>
     
    117117        Type serializerType = TypeLoader.Load(typeMapping.Serializer);
    118118        object serializer;
    119         if (serializerInstances.ContainsKey(serializerType))
     119        if (serializerInstances.ContainsKey(serializerType)) {
    120120          serializer = serializerInstances[serializerType];
    121         else
     121        } else {
    122122          serializer = Activator.CreateInstance(serializerType, true);
     123          serializerInstances.Add(serializerType, serializer);
     124        }
    123125        serializerMapping.Add(type, serializer);
    124       }
    125       catch (PersistenceException) {
     126      } catch (PersistenceException) {
    126127        throw;
    127       }
    128       catch (Exception e) {
     128      } catch (Exception e) {
    129129        throw new PersistenceException(string.Format(
    130130          "Could not add type info for {0} ({1})",
     
    181181      try {
    182182        parentStack.Push(new Midwife(type, (ICompositeSerializer)serializerMapping[type], token.Id));
    183       }
    184       catch (Exception e) {
     183      } catch (Exception e) {
    185184        if (e is InvalidCastException || e is KeyNotFoundException) {
    186185          throw new PersistenceException(String.Format(
     
    211210          id2obj[(int)token.Id] = value;
    212211        SetValue(token.Name, value);
    213       }
    214       catch (Exception e) {
     212      } catch (Exception e) {
    215213        if (e is InvalidCastException || e is KeyNotFoundException) {
    216214          throw new PersistenceException(String.Format(
Note: See TracChangeset for help on using the changeset viewer.