Changeset 17105 for stable/HeuristicLab.Optimizer/3.3/StartPage.cs
- Timestamp:
- 07/08/19 00:23:12 (5 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
-
stable/HeuristicLab.Optimizer
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Optimizer merged: 16585,16625,16658,16992,16997,17022-17023,17087
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimizer/3.3/StartPage.cs
r17097 r17105 27 27 using System.Threading; 28 28 using System.Windows.Forms; 29 using HEAL.Attic; 29 30 using HeuristicLab.Common; 30 31 using HeuristicLab.Core; 31 32 using HeuristicLab.MainForm; 32 using HeuristicLab.Persistence.Default.Xml;33 33 34 34 namespace HeuristicLab.Optimizer { … … 117 117 118 118 private void LoadSample(string name, Assembly assembly, ListViewGroup group, int count) { 119 string path = Path.GetTempFileName(); 120 try { 121 using (var stream = assembly.GetManifestResourceStream(name)) { 122 WriteStreamToTempFile(stream, path); // create a file in a temporary folder (persistence cannot load these files directly from the stream) 123 var item = XmlParser.Deserialize<INamedItem>(path); 124 OnSampleLoaded(item, group, 1.0 / count); 125 } 126 } catch (Exception) { 127 } finally { 128 if (File.Exists(path)) { 129 File.Delete(path); // make sure we remove the temporary file 130 } 119 using (var stream = assembly.GetManifestResourceStream(name)) { 120 var serializer = new ProtoBufSerializer(); 121 var item = (NamedItem)serializer.Deserialize(stream, false); 122 OnSampleLoaded(item, group, 1.0 / count); 131 123 } 132 124 } … … 199 191 Properties.Settings.Default.Save(); 200 192 } 201 202 #region Helpers203 private void WriteStreamToTempFile(Stream stream, string path) {204 using (FileStream output = new FileStream(path, FileMode.Create, FileAccess.Write)) {205 stream.CopyTo(output);206 }207 }208 #endregion209 193 } 210 194 }
Note: See TracChangeset
for help on using the changeset viewer.