Changeset 15035 for branches/PersistenceReintegration
- Timestamp:
- 06/16/17 13:36:53 (8 years ago)
- Location:
- branches/PersistenceReintegration
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceReintegration/HeuristicLab.Persistence/4.0/Core/StorableAttribute.cs
r14927 r15035 64 64 /// <summary> 65 65 /// 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 only67 /// 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. 68 68 /// </summary> 69 69 public bool AllowOneWay { get; set; } -
branches/PersistenceReintegration/HeuristicLab.Persistence/4.0/Transformers/StorableClassTransformer.cs
r15034 r15035 94 94 } 95 95 96 Dictionary<string, object> lastDict = new Dictionary<string, object>(); 96 97 foreach (var convMeth in conversionMethods) { 97 98 if (StorableConversionAttribute.GetVersion(convMeth) != version) 98 99 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 } 100 104 version++; 101 105 } … … 117 121 118 122 // set all members as generated by conversion method chain 119 foreach (var kvp in dict .ToArray()) {123 foreach (var kvp in dict) { 120 124 var key = kvp.Key; 121 125 var val = kvp.Value; … … 124 128 var field = (FieldInfo)fieldInfo.MemberInfo; 125 129 field.SetValue(obj, val); 126 dict.Remove(fieldInfo.Name);130 lastDict.Remove(fieldInfo.Name); // only for consistency check 127 131 continue; 128 132 } … … 131 135 var prop = (PropertyInfo)propInfo.MemberInfo; 132 136 prop.SetValue(obj, val, null); 133 dict.Remove(propInfo.Name);137 lastDict.Remove(propInfo.Name); // only for consistency check 134 138 continue; 135 139 } 136 140 } 137 141 138 if ( dict.Any())142 if (lastDict.Any()) 139 143 throw new PersistenceException(string.Format("Invalid conversion method. The following members are undefined in type {0} version {1}: {2}", 140 144 typeGuid, typeInfo.StorableTypeAttribute.Version, 141 string.Join(", ", dict.Keys)));145 string.Join(", ", lastDict.Keys))); 142 146 143 147 var emptyArgs = new object[0]; -
branches/PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCasesPersistenceNew.cs
r15034 r15035 2157 2157 [Storable] 2158 2158 public int y; 2159 2160 [Storable] 2161 public string s; 2159 2162 } 2160 2163 … … 2184 2187 [Storable] 2185 2188 public Point coords; 2189 2190 [Storable(Name = "s")] 2191 public string StorableString { get; set; } 2186 2192 } 2187 2193 … … 2202 2208 [Storable] 2203 2209 public Point coords; 2210 2211 [Storable(Name = "s", AllowOneWay = true)] 2212 public string StorableString { set { PublicString = value; } } 2213 public string PublicString { get; set; } 2204 2214 } 2205 2215 … … 2253 2263 var dv = new DoubleValue(1.0); 2254 2264 p.items = new ItemCollection<IItem>(new IItem[] { dv, dv, p.a }); 2265 p.s = "123"; 2255 2266 return p; 2256 2267 }); … … 2277 2288 // Assert.AreSame(restored.items[0], restored.items[1]); 2278 2289 Assert.AreSame(restored, restored.mySelf); 2279 2290 Assert.AreEqual(restored.PublicString, old.s); 2280 2291 //string msg = Profile(test); 2281 2292 //Console.WriteLine(msg);
Note: See TracChangeset
for help on using the changeset viewer.