Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/16/17 13:36:53 (7 years ago)
Author:
gkronber
Message:

#2520: made some changes related to renaming of storable members

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PersistenceReintegration/HeuristicLab.Persistence/4.0/Transformers/StorableClassTransformer.cs

    r15034 r15035  
    9494      }
    9595
     96      Dictionary<string, object> lastDict = new Dictionary<string, object>();
    9697      foreach (var convMeth in conversionMethods) {
    9798        if (StorableConversionAttribute.GetVersion(convMeth) != version)
    9899          throw new PersistenceException(string.Format("No conversion method defined for type {0} version {1}", typeGuid, version));
    99         dict = (Dictionary<string, object>)convMeth.Invoke(null, new object[] { dict });
     100        lastDict = (Dictionary<string, object>)convMeth.Invoke(null, new object[] { dict });
     101        foreach (var kvp in lastDict) {
     102          dict[kvp.Key] = kvp.Value;
     103        }
    100104        version++;
    101105      }
     
    117121
    118122      // set all members as generated by conversion method chain
    119       foreach (var kvp in dict.ToArray()) {
     123      foreach (var kvp in dict) {
    120124        var key = kvp.Key;
    121125        var val = kvp.Value;
     
    124128          var field = (FieldInfo)fieldInfo.MemberInfo;
    125129          field.SetValue(obj, val);
    126           dict.Remove(fieldInfo.Name);
     130          lastDict.Remove(fieldInfo.Name); // only for consistency check
    127131          continue;
    128132        }
     
    131135          var prop = (PropertyInfo)propInfo.MemberInfo;
    132136          prop.SetValue(obj, val, null);
    133           dict.Remove(propInfo.Name);
     137          lastDict.Remove(propInfo.Name);    // only for consistency check
    134138          continue;
    135139        }
    136140      }
    137141
    138       if (dict.Any())
     142      if (lastDict.Any())
    139143        throw new PersistenceException(string.Format("Invalid conversion method. The following members are undefined in type {0} version {1}: {2}",
    140144          typeGuid, typeInfo.StorableTypeAttribute.Version,
    141           string.Join(", ", dict.Keys)));
     145          string.Join(", ", lastDict.Keys)));
    142146
    143147      var emptyArgs = new object[0];
Note: See TracChangeset for help on using the changeset viewer.