Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/11/19 14:38:47 (5 years ago)
Author:
jkarder
Message:

#2520: changed deserialization in PersistenceContentManager

  • added method to check if old persistence can open a file
  • used this method to determine which persistence to use
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Core/3.3/PersistenceContentManager.cs

    r16933 r16945  
    3131
    3232    protected override IStorableContent LoadContent(string filename) {
    33       // first try to load using the new persistence format
     33      bool useOldPersistence = XmlParser.CanOpen(filename);
     34      if (useOldPersistence) return XmlParser.Deserialize<IStorableContent>(filename);
     35
    3436      var ser = new ProtoBufSerializer();
    35       try {
    36         return (IStorableContent)ser.Deserialize(filename, out SerializationInfo info);
    37       } catch (Exception e) {
    38         try {
    39           // try old format if new format fails
    40           return XmlParser.Deserialize<IStorableContent>(filename);
    41         } catch (Exception e2) {
    42           throw new AggregateException($"Cannot open file {filename}", e, e2);
    43         }
    44       }
     37      return (IStorableContent)ser.Deserialize(filename, out SerializationInfo info);
    4538    }
    4639
Note: See TracChangeset for help on using the changeset viewer.