Changeset 14930 for branches/PersistenceReintegration
- Timestamp:
- 05/04/17 19:53:35 (8 years ago)
- Location:
- branches/PersistenceReintegration
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceReintegration/HeuristicLab.Common/3.3/Content/ContentManager.cs
r14927 r14930 57 57 protected abstract IStorableContent LoadContent(string filename); 58 58 59 public static void Save(IStorableContent content, string filename , bool compressed) {59 public static void Save(IStorableContent content, string filename) { 60 60 if (instance == null) throw new InvalidOperationException("ContentManager is not initialized."); 61 instance.SaveContent(content, filename , compressed);61 instance.SaveContent(content, filename); 62 62 content.Filename = filename; 63 63 } 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) { 65 65 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) { 68 68 Exception error = null; 69 69 try { … … 77 77 78 78 } 79 protected abstract void SaveContent(IStorableContent content, string filename , bool compressed);79 protected abstract void SaveContent(IStorableContent content, string filename); 80 80 } 81 81 } -
branches/PersistenceReintegration/HeuristicLab.Core.Views/3.3/Clipboard.cs
r14927 r14930 30 30 using HeuristicLab.Common; 31 31 using HeuristicLab.MainForm; 32 using HeuristicLab.Persistence; 32 33 using HeuristicLab.Persistence.Default.Xml; 33 34 using HeuristicLab.PluginInfrastructure; … … 155 156 foreach (string filename in items) { 156 157 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 158 167 OnItemLoaded(item, progressBar.Maximum / items.Length); 159 168 } catch (Exception) { } … … 197 206 i++; 198 207 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"); 200 209 OnItemSaved(item, progressBar.Maximum / listView.Items.Count); 201 210 } catch (Exception) { } finally { -
branches/PersistenceReintegration/HeuristicLab.Core/3.3/PersistenceContentManager.cs
r14185 r14930 20 20 #endregion 21 21 22 using System .IO.Compression;22 using System; 23 23 using HeuristicLab.Common; 24 using HeuristicLab.Persistence.Default.Xml;25 24 26 25 namespace HeuristicLab.Core { … … 29 28 30 29 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 32 40 } 33 41 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); 36 47 } 37 48 } -
branches/PersistenceReintegration/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.cs
r14185 r14930 206 206 Title = "Save Item", 207 207 DefaultExt = "hl", 208 Filter = " Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*",209 FilterIndex = 2208 Filter = "HeuristicLab Files|*.hl|All Files|*.*", 209 FilterIndex = 1 210 210 }; 211 211 … … 219 219 try { 220 220 mainForm.AddOperationProgressToContent(activeView.Content, "Exporting data."); 221 ContentManager.Save(storable, saveFileDialog.FileName, compressed);221 PersistenceContentManager.Save(storable, saveFileDialog.FileName); 222 222 } finally { 223 223 mainForm.RemoveOperationProgressFromContent(activeView.Content); -
branches/PersistenceReintegration/HeuristicLab.Optimizer/3.3/FileManager.cs
r14185 r14930 78 78 if (view == null) 79 79 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) { 82 81 ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, "Cannot open file.", ex); 83 } 84 finally { 82 } finally { 85 83 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).ResetAppStartingCursor(); 86 84 } … … 101 99 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor(); 102 100 SetSaveOperationProgressInContentViews(content, true); 103 ContentManager.SaveAsync(content, content.Filename, true,SavingCompleted);101 ContentManager.SaveAsync(content, content.Filename, SavingCompleted); 104 102 } 105 103 } … … 118 116 saveFileDialog.Title = "Save Item"; 119 117 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; 122 120 } 123 121 … … 133 131 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor(); 134 132 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); 140 134 } 141 135 } … … 145 139 if (error != null) throw error; 146 140 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().UpdateTitle(); 147 } 148 catch (Exception ex) { 141 } catch (Exception ex) { 149 142 ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, "Cannot save file.", ex); 150 } 151 finally { 143 } finally { 152 144 SetSaveOperationProgressInContentViews(content, false); 153 145 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().ResetAppStartingCursor(); -
branches/PersistenceReintegration/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.cs
r14927 r14930 126 126 if (loadProblemDataFileDialog.ShowDialog(this) != DialogResult.OK) return; 127 127 try { 128 object hlFile = XmlParser.Deserialize(loadProblemDataFileDialog.FileName);128 object hlFile = PersistenceContentManager.Load(loadProblemDataFileDialog.FileName); 129 129 130 130 IDataAnalysisProblemData problemData = null;
Note: See TracChangeset
for help on using the changeset viewer.