- Timestamp:
- 06/25/19 23:14:06 (5 years ago)
- Location:
- branches/2435-alglib_3_15
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2435-alglib_3_15
- Property svn:mergeinfo changed
-
branches/2435-alglib_3_15/HeuristicLab.Core
- Property svn:mergeinfo changed
/branches/2931_OR-Tools_LP_MIP/HeuristicLab.Core (added) merged: 16373 /trunk/HeuristicLab.Core (added) merged: 16872,16907,16910,16933,16942,16945,16992,17009
- Property svn:mergeinfo changed
-
branches/2435-alglib_3_15/HeuristicLab.Core/3.3/PersistenceContentManager.cs
r16579 r17034 25 25 using HEAL.Attic; 26 26 using System; 27 using System.Diagnostics; 27 28 28 29 namespace HeuristicLab.Core { … … 30 31 public PersistenceContentManager() : base() { } 31 32 32 protected override IStorableContent LoadContent(string filename) { 33 // first try to load using the new persistence format 34 try { 33 protected override IStorableContent LoadContent(string filename, out Info info) { 34 bool useOldPersistence = XmlParser.CanOpen(filename); 35 IStorableContent content = null; 36 if (useOldPersistence) { 37 var sw = new Stopwatch(); 38 sw.Start(); 39 content = XmlParser.Deserialize<IStorableContent>(filename); 40 sw.Stop(); 41 info = new Info(filename, sw.Elapsed); 42 } else { 35 43 var ser = new ProtoBufSerializer(); 36 return (IStorableContent)ser.Deserialize(filename); 37 } catch (Exception) { 38 // try old format if new format fails 39 return XmlParser.Deserialize<IStorableContent>(filename); 44 content = (IStorableContent)ser.Deserialize(filename, out SerializationInfo serInfo); 45 info = new Info(filename, serInfo); 40 46 } 47 if (content == null) throw new PersistenceException($"Cannot deserialize root element of {filename}"); 48 return content; 41 49 } 50 42 51 43 52 protected override void SaveContent(IStorableContent content, string filename, bool compressed, CancellationToken cancellationToken) { 44 53 var ser = new ProtoBufSerializer(); 45 ser.Serialize(content, filename, cancellationToken); 54 ser.Serialize(content, filename, cancellationToken); 46 55 } 47 56 }
Note: See TracChangeset
for help on using the changeset viewer.