Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/31/19 13:56:47 (5 years ago)
Author:
gkronber
Message:

#2925: merged r16992:16997 from trunk to branch

Location:
branches/2925_AutoDiffForDynamicalModels
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2925_AutoDiffForDynamicalModels

  • branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Core

  • branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Core/3.3/PersistenceContentManager.cs

    r16988 r17000  
    2525using HEAL.Attic;
    2626using System;
     27using System.Diagnostics;
    2728
    2829namespace HeuristicLab.Core {
     
    3031    public PersistenceContentManager() : base() { }
    3132
    32     protected override IStorableContent LoadContent(string filename) {
     33    protected override IStorableContent LoadContent(string filename, out Info info) {
    3334      bool useOldPersistence = XmlParser.CanOpen(filename);
    34       if (useOldPersistence) return XmlParser.Deserialize<IStorableContent>(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 {
     43        var ser = new ProtoBufSerializer();
     44        content = (IStorableContent)ser.Deserialize(filename, out SerializationInfo serInfo);
     45        info = new Info(filename, serInfo);
     46      }
     47      if (content == null) throw new PersistenceException($"Cannot deserialize root element of {filename}");
     48      return content;
     49    }
    3550
    36       var ser = new ProtoBufSerializer();
    37       return (IStorableContent)ser.Deserialize(filename, out SerializationInfo info);
    38     }
    3951
    4052    protected override void SaveContent(IStorableContent content, string filename, bool compressed, CancellationToken cancellationToken) {
Note: See TracChangeset for help on using the changeset viewer.