Changeset 14930


Ignore:
Timestamp:
05/04/17 19:53:35 (2 years ago)
Author:
gkronber
Message:

#2520 changed optimizer to use new persistence per default

Location:
branches/PersistenceReintegration
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/PersistenceReintegration/HeuristicLab.Common/3.3/Content/ContentManager.cs

    r14927 r14930  
    5757    protected abstract IStorableContent LoadContent(string filename);
    5858
    59     public static void Save(IStorableContent content, string filename, bool compressed) {
     59    public static void Save(IStorableContent content, string filename) {
    6060      if (instance == null) throw new InvalidOperationException("ContentManager is not initialized.");
    61       instance.SaveContent(content, filename, compressed);
     61      instance.SaveContent(content, filename);
    6262      content.Filename = filename;
    6363    }
    64     public static void SaveAsync(IStorableContent content, string filename, bool compressed, Action<IStorableContent, Exception> savingCompletedCallback) {
     64    public static void SaveAsync(IStorableContent content, string filename, Action<IStorableContent, Exception> savingCompletedCallback) {
    6565      if (instance == null) throw new InvalidOperationException("ContentManager is not initialized.");
    66       var action = new Action<IStorableContent, string, bool>(instance.SaveContent);
    67       action.BeginInvoke(content, filename, compressed, delegate (IAsyncResult result) {
     66      var action = new Action<IStorableContent, string>(instance.SaveContent);
     67      action.BeginInvoke(content, filename, delegate (IAsyncResult result) {
    6868        Exception error = null;
    6969        try {
     
    7777
    7878    }
    79     protected abstract void SaveContent(IStorableContent content, string filename, bool compressed);
     79    protected abstract void SaveContent(IStorableContent content, string filename);
    8080  }
    8181}
  • branches/PersistenceReintegration/HeuristicLab.Core.Views/3.3/Clipboard.cs

    r14927 r14930  
    3030using HeuristicLab.Common;
    3131using HeuristicLab.MainForm;
     32using HeuristicLab.Persistence;
    3233using HeuristicLab.Persistence.Default.Xml;
    3334using HeuristicLab.PluginInfrastructure;
     
    155156      foreach (string filename in items) {
    156157        try {
    157           T item = XmlParser.Deserialize<T>(filename);
     158
     159          #region backwards compatibility
     160          T item = null;
     161          try {
     162            item = XmlParser.Deserialize<T>(filename);
     163          } catch(Exception e) { }
     164          if (item == null)
     165            item = (T)(new ProtoBufSerializer()).Deserialize(filename);
     166          #endregion
    158167          OnItemLoaded(item, progressBar.Maximum / items.Length);
    159168        } catch (Exception) { }
     
    197206          i++;
    198207          SetEnabledStateOfContentViews(item, false);
    199           XmlGenerator.Serialize(item, ItemsPath + Path.DirectorySeparatorChar + i.ToString("00000000") + ".hl", CompressionLevel.Optimal);
     208          (new ProtoBufSerializer()).Serialize(item, ItemsPath + Path.DirectorySeparatorChar + i.ToString("00000000") + ".hl");
    200209          OnItemSaved(item, progressBar.Maximum / listView.Items.Count);
    201210        } catch (Exception) { } finally {
  • branches/PersistenceReintegration/HeuristicLab.Core/3.3/PersistenceContentManager.cs

    r14185 r14930  
    2020#endregion
    2121
    22 using System.IO.Compression;
     22using System;
    2323using HeuristicLab.Common;
    24 using HeuristicLab.Persistence.Default.Xml;
    2524
    2625namespace HeuristicLab.Core {
     
    2928
    3029    protected override IStorableContent LoadContent(string filename) {
    31       return XmlParser.Deserialize<IStorableContent>(filename);
     30      #region backwards compatibility
     31      // try to deserialize with new serializer first
     32      var serializer = new HeuristicLab.Persistence.ProtoBufSerializer();
     33      IStorableContent content;
     34      try {
     35        content = (IStorableContent)serializer.Deserialize(filename);
     36        return content;
     37      } catch (Exception e) { }
     38      return HeuristicLab.Persistence.Default.Xml.XmlParser.Deserialize<IStorableContent>(filename);
     39      #endregion
    3240    }
    3341
    34     protected override void SaveContent(IStorableContent content, string filename, bool compressed) {
    35       XmlGenerator.Serialize(content, filename, compressed ? CompressionLevel.Optimal : CompressionLevel.NoCompression);
     42    protected override void SaveContent(IStorableContent content, string filename) {
     43      // XmlGenerator.Serialize(content, filename, compressed ? CompressionLevel.Optimal : CompressionLevel.NoCompression);
     44
     45      var serializer = new HeuristicLab.Persistence.ProtoBufSerializer();
     46      serializer.Serialize(content, filename);
    3647    }
    3748  }
  • branches/PersistenceReintegration/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.cs

    r14185 r14930  
    206206        Title = "Save Item",
    207207        DefaultExt = "hl",
    208         Filter = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*",
    209         FilterIndex = 2
     208        Filter = "HeuristicLab Files|*.hl|All Files|*.*",
     209        FilterIndex = 1
    210210      };
    211211
     
    219219            try {
    220220              mainForm.AddOperationProgressToContent(activeView.Content, "Exporting data.");
    221               ContentManager.Save(storable, saveFileDialog.FileName, compressed);
     221              PersistenceContentManager.Save(storable, saveFileDialog.FileName);
    222222            } finally {
    223223              mainForm.RemoveOperationProgressFromContent(activeView.Content);
  • branches/PersistenceReintegration/HeuristicLab.Optimizer/3.3/FileManager.cs

    r14185 r14930  
    7878        if (view == null)
    7979          ErrorHandling.ShowErrorDialog("There is no view for the loaded item. It cannot be displayed.", new InvalidOperationException("No View Available"));
    80       }
    81       catch (Exception ex) {
     80      } catch (Exception ex) {
    8281        ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, "Cannot open file.", ex);
    83       }
    84       finally {
     82      } finally {
    8583        ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).ResetAppStartingCursor();
    8684      }
     
    10199          MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor();
    102100          SetSaveOperationProgressInContentViews(content, true);
    103           ContentManager.SaveAsync(content, content.Filename, true, SavingCompleted);
     101          ContentManager.SaveAsync(content, content.Filename, SavingCompleted);
    104102        }
    105103      }
     
    118116          saveFileDialog.Title = "Save Item";
    119117          saveFileDialog.DefaultExt = "hl";
    120           saveFileDialog.Filter = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*";
    121           saveFileDialog.FilterIndex = 2;
     118          saveFileDialog.Filter = "HeuristicLab Files|*.hl|All Files|*.*";
     119          saveFileDialog.FilterIndex = 1;
    122120        }
    123121
     
    133131          MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor();
    134132          SetSaveOperationProgressInContentViews(content, true, saveFileDialog.FileName);
    135           if (saveFileDialog.FilterIndex == 1) {
    136             ContentManager.SaveAsync(content, saveFileDialog.FileName, false, SavingCompleted);
    137           } else {
    138             ContentManager.SaveAsync(content, saveFileDialog.FileName, true, SavingCompleted);
    139           }
     133          ContentManager.SaveAsync(content, saveFileDialog.FileName, SavingCompleted);
    140134        }
    141135      }
     
    145139        if (error != null) throw error;
    146140        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().UpdateTitle();
    147       }
    148       catch (Exception ex) {
     141      } catch (Exception ex) {
    149142        ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, "Cannot save file.", ex);
    150       }
    151       finally {
     143      } finally {
    152144        SetSaveOperationProgressInContentViews(content, false);
    153145        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().ResetAppStartingCursor();
  • branches/PersistenceReintegration/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.cs

    r14927 r14930  
    126126      if (loadProblemDataFileDialog.ShowDialog(this) != DialogResult.OK) return;
    127127      try {
    128         object hlFile = XmlParser.Deserialize(loadProblemDataFileDialog.FileName);
     128        object hlFile = PersistenceContentManager.Load(loadProblemDataFileDialog.FileName);
    129129
    130130        IDataAnalysisProblemData problemData = null;
Note: See TracChangeset for help on using the changeset viewer.