Changeset 15035


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

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

Location:
branches/PersistenceReintegration
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/PersistenceReintegration/HeuristicLab.Persistence/4.0/Core/StorableAttribute.cs

    r14927 r15035  
    6464    /// <summary>
    6565    /// Allow storable attribute on properties with only a getter or a setter. These
    66     /// properties will then by either only serialized but not deserialized or only
    67     /// deserialized (if stored) but not serialized again.
     66    /// properties will then by either only serialized (getter only) but not deserialized or only
     67    /// deserialized (setter only) but not serialized again.
    6868    /// </summary>
    6969    public bool AllowOneWay { get; set; }
  • 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];
  • branches/PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCasesPersistenceNew.cs

    r15034 r15035  
    21572157      [Storable]
    21582158      public int y;
     2159
     2160      [Storable]
     2161      public string s;
    21592162    }
    21602163
     
    21842187      [Storable]
    21852188      public Point coords;
     2189
     2190      [Storable(Name = "s")]
     2191      public string StorableString { get; set; }
    21862192    }
    21872193
     
    22022208      [Storable]
    22032209      public Point coords;
     2210
     2211      [Storable(Name = "s", AllowOneWay = true)]
     2212      public string StorableString {  set { PublicString = value; } }
     2213      public string PublicString { get; set; }
    22042214    }
    22052215
     
    22532263        var dv = new DoubleValue(1.0);
    22542264        p.items = new ItemCollection<IItem>(new IItem[] { dv, dv, p.a });
     2265        p.s = "123";
    22552266        return p;
    22562267      });
     
    22772288      // Assert.AreSame(restored.items[0], restored.items[1]);
    22782289      Assert.AreSame(restored, restored.mySelf);
    2279 
     2290      Assert.AreEqual(restored.PublicString, old.s);
    22802291      //string msg = Profile(test);
    22812292      //Console.WriteLine(msg);
Note: See TracChangeset for help on using the changeset viewer.