- Timestamp:
- 07/08/19 00:23:12 (6 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
-
stable/HeuristicLab.Core
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Core merged: 16585,16625,16658,16907,16933,16945,16992
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Core/3.3/PersistenceContentManager.cs
r17097 r17105 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.