Changeset 17068
- Timestamp:
- 07/04/19 15:26:27 (5 years ago)
- Location:
- stable
- Files:
-
- 86 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
-
stable/.editorconfig
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/.editorconfig (added) merged: 16433 /trunk/.editorconfig reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.ALPS
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Algorithms.ALPS (added) merged: 16433 /trunk/HeuristicLab.Algorithms.ALPS reverse-merged: 16117,16356,16389 /trunk/sources/HeuristicLab.Algorithms.ALPS reverse-merged: 15581,15583,15589
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis/3.4
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.MOCMAEvolutionStrategy
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Analysis
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Analysis (added) merged: 16433 /trunk/HeuristicLab.Analysis reverse-merged: 16117,16177,16356,16389 /trunk/sources/HeuristicLab.Analysis reverse-merged: 15581,15583,15589
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Analysis.Views
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Analysis.Views (added) merged: 16433 /trunk/HeuristicLab.Analysis.Views reverse-merged: 16117,16356,16389 /trunk/sources/HeuristicLab.Analysis.Views reverse-merged: 15581,15583,15589,15619
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.Access
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Clients.Access (added) merged: 16433 /trunk/HeuristicLab.Clients.Access reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.Access.Administration
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Clients.Access.Administration (added) merged: 16433 /trunk/HeuristicLab.Clients.Access.Administration reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.Access.Views
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Clients.Access.Views (added) merged: 16433 /trunk/HeuristicLab.Clients.Access.Views reverse-merged: 16117,16186-16187,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.Common
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Clients.Common (added) merged: 16433 /trunk/HeuristicLab.Clients.Common reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.Hive
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Clients.Hive (added) merged: 16433 /trunk/HeuristicLab.Clients.Hive reverse-merged: 16117,16202,16204-16205,16208-16209,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.Hive.Administrator
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.Hive.JobManager
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.Hive.Slave
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Clients.Hive.Slave (added) merged: 16433 /trunk/HeuristicLab.Clients.Hive.Slave reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.Hive.Slave.WindowsService
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Clients.Hive.Slave.WindowsService (added) merged: 16433 /trunk/HeuristicLab.Clients.Hive.Slave.WindowsService reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.Hive.Views
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Clients.Hive.Views (added) merged: 16433 /trunk/HeuristicLab.Clients.Hive.Views reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.OKB.Views
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Clients.OKB.Views (added) merged: 16433 /trunk/HeuristicLab.Clients.OKB.Views reverse-merged: 16024-16025,16032-16033,16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Common/3.3/Content/ContentManager.cs
r15584 r17068 21 21 22 22 using System; 23 using System.Threading; 23 24 24 25 namespace HeuristicLab.Common { … … 43 44 if (instance == null) throw new InvalidOperationException("ContentManager is not initialized."); 44 45 var func = new Func<string, IStorableContent>(instance.LoadContent); 45 func.BeginInvoke(filename, delegate (IAsyncResult result) {46 func.BeginInvoke(filename, delegate (IAsyncResult result) { 46 47 Exception error = null; 47 48 IStorableContent content = null; … … 49 50 content = func.EndInvoke(result); 50 51 content.Filename = filename; 51 } 52 catch (Exception ex) { 52 } catch (Exception ex) { 53 53 error = ex; 54 54 } … … 58 58 protected abstract IStorableContent LoadContent(string filename); 59 59 60 public static void Save(IStorableContent content, string filename, bool compressed ) {60 public static void Save(IStorableContent content, string filename, bool compressed, CancellationToken cancellationToken = default(CancellationToken)) { 61 61 if (instance == null) throw new InvalidOperationException("ContentManager is not initialized."); 62 instance.SaveContent(content, filename, compressed );62 instance.SaveContent(content, filename, compressed, cancellationToken); 63 63 content.Filename = filename; 64 64 } 65 public static void SaveAsync(IStorableContent content, string filename, bool compressed, Action<IStorableContent, Exception> savingCompletedCallback ) {65 public static void SaveAsync(IStorableContent content, string filename, bool compressed, Action<IStorableContent, Exception> savingCompletedCallback, CancellationToken cancellationToken = default(CancellationToken)) { 66 66 if (instance == null) throw new InvalidOperationException("ContentManager is not initialized."); 67 var action = new Action<IStorableContent, string, bool >(instance.SaveContent);68 action.BeginInvoke(content, filename, compressed, delegate(IAsyncResult result) {67 var action = new Action<IStorableContent, string, bool, CancellationToken>(instance.SaveContent); 68 action.BeginInvoke(content, filename, compressed, cancellationToken, delegate (IAsyncResult result) { 69 69 Exception error = null; 70 70 try { 71 71 action.EndInvoke(result); 72 72 content.Filename = filename; 73 } 74 catch (Exception ex) { 73 } catch (Exception ex) { 75 74 error = ex; 76 75 } … … 79 78 80 79 } 81 protected abstract void SaveContent(IStorableContent content, string filename, bool compressed );80 protected abstract void SaveContent(IStorableContent content, string filename, bool compressed, CancellationToken cancellationToken); 82 81 } 83 82 } -
stable/HeuristicLab.Core
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Core (added) merged: 16325,16433 /trunk/HeuristicLab.Core reverse-merged: 16117,16356,16389 /trunk/sources/HeuristicLab.Core reverse-merged: 15581,15583,15589
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Core.Views
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Core.Views (added) merged: 16433 /trunk/HeuristicLab.Core.Views reverse-merged: 15706-15707,16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Core.Views/3.3/TypeSelector.cs
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Core/3.3/PersistenceContentManager.cs
r15584 r17068 21 21 22 22 using System.IO.Compression; 23 using System.Threading; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Persistence.Default.Xml; … … 32 33 } 33 34 34 protected override void SaveContent(IStorableContent content, string filename, bool compressed ) {35 XmlGenerator.Serialize(content, filename, compressed ? CompressionLevel.Optimal : CompressionLevel.NoCompression );35 protected override void SaveContent(IStorableContent content, string filename, bool compressed, CancellationToken cancellationToken) { 36 XmlGenerator.Serialize(content, filename, compressed ? CompressionLevel.Optimal : CompressionLevel.NoCompression, cancellationToken); 36 37 } 37 38 } -
stable/HeuristicLab.Data
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Data (added) merged: 16433 /trunk/HeuristicLab.Data reverse-merged: 15931-15932,15934,16117,16280,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Data.Views
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Data.Views (added) merged: 16433 /trunk/HeuristicLab.Data.Views reverse-merged: 16117,16356,16389 /trunk/sources/HeuristicLab.Data.Views reverse-merged: 15548,15581,15583,15589
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Data.Views/3.3
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Data.Views/3.3 (added) merged: 16433 /trunk/HeuristicLab.Data.Views/3.3 reverse-merged: 16117,16356,16389 /trunk/sources/HeuristicLab.Data.Views/3.3 reverse-merged: 15548,15581,15583,15589
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Data/3.3
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Data/3.3 (added) merged: 16433 /trunk/HeuristicLab.Data/3.3 reverse-merged: 15931-15932,15934,16117,16280,16356,16389 /trunk/sources/HeuristicLab.Data/3.3 reverse-merged: 15581,15583,15589
- Property svn:mergeinfo changed
-
stable/HeuristicLab.DataPreprocessing
- Property svn:mergeinfo changed
-
stable/HeuristicLab.DataPreprocessing.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.DataPreprocessing/3.4
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.BinaryVectorEncoding
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.IntegerVectorEncoding
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.PermutationEncoding
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.RealVectorEncoding
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.ExtLibs
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimization
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimization.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimization/3.3/Problems/SingleObjectiveHeuristicOptimizationProblem.cs
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimizer
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Optimizer (added) merged: 16325,16433 /trunk/HeuristicLab.Optimizer reverse-merged: 16117,16356,16389 /trunk/sources/HeuristicLab.Optimizer reverse-merged: 15581,15583,15589,15591
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimizer/3.3/FileManager.cs
r17062 r17068 23 23 using System.Collections.Generic; 24 24 using System.IO; 25 using System.Threading; 25 26 using System.Windows.Forms; 26 27 using HeuristicLab.Common; … … 98 99 else { 99 100 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor(); 100 SetSaveOperationProgressInContentViews(content, true); 101 ContentManager.SaveAsync(content, content.Filename, true, SavingCompleted); 101 var cancellationTokenSource = new CancellationTokenSource(); 102 AddProgressInContentViews(content, cancellationTokenSource); 103 ContentManager.SaveAsync(content, content.Filename, true, SavingCompleted, cancellationTokenSource.Token); 102 104 } 103 105 } … … 130 132 if (saveFileDialog.ShowDialog() == DialogResult.OK) { 131 133 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor(); 132 SetSaveOperationProgressInContentViews(content, true, saveFileDialog.FileName); 133 if (saveFileDialog.FilterIndex == 1) { 134 ContentManager.SaveAsync(content, saveFileDialog.FileName, false, SavingCompleted); 135 } else { 136 ContentManager.SaveAsync(content, saveFileDialog.FileName, true, SavingCompleted); 137 } 134 bool compressed = saveFileDialog.FilterIndex != 1; 135 var cancellationTokenSource = new CancellationTokenSource(); 136 AddProgressInContentViews(content, cancellationTokenSource, saveFileDialog.FileName); 137 138 ContentManager.SaveAsync(content, saveFileDialog.FileName, compressed, SavingCompleted, cancellationTokenSource.Token); 138 139 } 139 140 } … … 143 144 if (error != null) throw error; 144 145 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().UpdateTitle(); 146 } catch (OperationCanceledException) { // do nothing if canceled 145 147 } catch (Exception ex) { 146 148 ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, "Cannot save file.", ex); 147 149 } finally { 148 SetSaveOperationProgressInContentViews(content, false);150 Progress.Hide(content); 149 151 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().ResetAppStartingCursor(); 150 152 } 151 153 } 152 154 153 private static void SetSaveOperationProgressInContentViews(IStorableContent content, bool showProgress, string fileName = null) { 154 HeuristicLab.MainForm.WindowsForms.MainForm mainForm = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>(); 155 #region Mono Compatibility 156 // removed the InvokeRequired check because of Mono 157 mainForm.Invoke((Action)delegate { 158 if (showProgress) { 159 Progress.Show(content, string.Format("Saving to file \"{0}\"...", Path.GetFileName(fileName ?? content.Filename))); 160 } else 161 Progress.Hide(content); 162 }); 163 #endregion 155 private static void AddProgressInContentViews(IStorableContent content, CancellationTokenSource cancellationTokenSource, string fileName = null) { 156 string message = string.Format("Saving to file \"{0}\"...", Path.GetFileName(fileName ?? content.Filename)); 157 Progress.Show(content, message, ProgressMode.Indeterminate, cancelRequestHandler: () => cancellationTokenSource.Cancel()); 164 158 } 165 159 } -
stable/HeuristicLab.Persistence
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Persistence (added) merged: 16325,16433 /trunk/HeuristicLab.Persistence reverse-merged: 16117,16356,16389 /trunk/sources/HeuristicLab.Persistence reverse-merged: 15581,15583,15589
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs
r15584 r17068 26 26 using System.Linq; 27 27 using System.Text; 28 using System.Threading; 28 29 using HeuristicLab.Persistence.Core; 29 30 using HeuristicLab.Persistence.Core.Tokens; … … 61 62 } 62 63 63 protected enum NodeType { Start, End, Inline } 64 protected enum NodeType { Start, End, Inline }; 64 65 65 66 protected static void AddXmlTagContent(StringBuilder sb, string name, Dictionary<string, string> attributes) { … … 256 257 {"typeName", lastTypeToken.TypeName }, 257 258 {"serializer", lastTypeToken.Serializer }}); 258 } 259 finally { 259 } finally { 260 260 lastTypeToken = null; 261 261 } … … 284 284 /// <param name="o">The object.</param> 285 285 /// <param name="filename">The filename.</param> 286 public static void Serialize(object o, string filename ) {287 Serialize(o, filename, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, CompressionLevel.Optimal );286 public static void Serialize(object o, string filename, CancellationToken cancellationToken = default(CancellationToken)) { 287 Serialize(o, filename, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, CompressionLevel.Optimal, cancellationToken); 288 288 } 289 289 … … 296 296 /// <param name="filename">The filename.</param> 297 297 /// <param name="compression">ZIP file compression level</param> 298 public static void Serialize(object o, string filename, CompressionLevel compression ) {299 Serialize(o, filename, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, compression );298 public static void Serialize(object o, string filename, CompressionLevel compression, CancellationToken cancellationToken = default(CancellationToken)) { 299 Serialize(o, filename, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, compression, cancellationToken); 300 300 } 301 301 … … 307 307 /// <param name="filename">The filename.</param> 308 308 /// <param name="config">The configuration.</param> 309 public static void Serialize(object obj, string filename, Configuration config) { 310 Serialize(obj, filename, config, false, CompressionLevel.Optimal); 311 } 312 313 private static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies 314 , CompressionLevel compression) { 309 public static void Serialize(object obj, string filename, Configuration config, CancellationToken cancellationToken = default(CancellationToken)) { 310 Serialize(obj, filename, config, false, CompressionLevel.Optimal, cancellationToken); 311 } 312 313 private static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies, CompressionLevel compression, CancellationToken cancellationToken = default(CancellationToken)) { 315 314 Serializer serializer = new Serializer(obj, config); 316 Serialize(stream, includeAssemblies, compression, serializer );317 } 318 319 private static void Serialize(Stream stream, bool includeAssemblies, CompressionLevel compression, Serializer serializer ) {315 Serialize(stream, includeAssemblies, compression, serializer, cancellationToken); 316 } 317 318 private static void Serialize(Stream stream, bool includeAssemblies, CompressionLevel compression, Serializer serializer, CancellationToken cancellationToken = default(CancellationToken)) { 320 319 try { 320 cancellationToken.ThrowIfCancellationRequested(); 321 321 DateTime start = DateTime.Now; 322 322 serializer.InterleaveTypeInformation = false; … … 326 326 using (StreamWriter writer = new StreamWriter(entry.Open())) { 327 327 foreach (ISerializationToken token in serializer) { 328 cancellationToken.ThrowIfCancellationRequested(); 328 329 string line = generator.Format(token); 329 330 writer.Write(line); … … 338 339 if (includeAssemblies) { 339 340 foreach (string name in serializer.RequiredFiles) { 341 cancellationToken.ThrowIfCancellationRequested(); 340 342 Uri uri = new Uri(name); 341 343 if (!uri.IsFile) { … … 348 350 byte[] buffer = new byte[1024 * 1024]; 349 351 while (true) { 352 cancellationToken.ThrowIfCancellationRequested(); 350 353 int bytesRead = reader.Read(buffer, 0, 1024 * 1024); 351 354 if (bytesRead == 0) … … 360 363 Logger.Info(String.Format("serialization took {0} seconds with compression level {1}", 361 364 (DateTime.Now - start).TotalSeconds, compression)); 362 } 363 catch (Exception) { 365 } catch (Exception) { 364 366 Logger.Warn("Exception caught, no data has been serialized."); 365 367 throw; … … 375 377 /// <param name="includeAssemblies">if set to <c>true</c> include needed assemblies.</param> 376 378 /// <param name="compression">The ZIP compression level.</param> 377 public static void Serialize(object obj, string filename, Configuration config, bool includeAssemblies, CompressionLevel compression) { 379 public static void Serialize(object obj, string filename, Configuration config, bool includeAssemblies, CompressionLevel compression, CancellationToken cancellationToken = default(CancellationToken)) { 380 string tempfile = null; 378 381 try { 379 stringtempfile = Path.GetTempFileName();382 tempfile = Path.GetTempFileName(); 380 383 381 384 using (FileStream stream = File.Create(tempfile)) { 382 Serialize(obj, stream, config, includeAssemblies, compression );383 } 384 385 Serialize(obj, stream, config, includeAssemblies, compression, cancellationToken); 386 } 387 // copy only if needed 385 388 File.Copy(tempfile, filename, true); 386 File.Delete(tempfile); 387 } 388 catch (Exception) { 389 } catch (Exception) { 389 390 Logger.Warn("Exception caught, no data has been written."); 390 391 throw; 392 } finally { 393 if (tempfile != null && File.Exists(tempfile)) 394 File.Delete(tempfile); 391 395 } 392 396 } … … 399 403 /// <param name="stream">The stream.</param> 400 404 /// <param name="compressionType">Type of compression, default is GZip.</param> 401 public static void Serialize(object obj, Stream stream, CompressionType compressionType = CompressionType.GZip ) {402 Serialize(obj, stream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), compressionType );405 public static void Serialize(object obj, Stream stream, CompressionType compressionType = CompressionType.GZip, CancellationToken cancellationToken = default(CancellationToken)) { 406 Serialize(obj, stream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), compressionType, cancellationToken); 403 407 } 404 408 … … 411 415 /// <param name="config">The configuration.</param> 412 416 /// <param name="compressionType">Type of compression, default is GZip.</param> 413 public static void Serialize(object obj, Stream stream, Configuration config, CompressionType compressionType = CompressionType.GZip ) {414 Serialize(obj, stream, config, false, compressionType );417 public static void Serialize(object obj, Stream stream, Configuration config, CompressionType compressionType = CompressionType.GZip, CancellationToken cancellationToken = default(CancellationToken)) { 418 Serialize(obj, stream, config, false, compressionType, cancellationToken); 415 419 } 416 420 … … 423 427 /// <param name="includeAssemblies">if set to <c>true</c> include need assemblies.</param> 424 428 /// <param name="compressionType">Type of compression, default is GZip.</param> 425 public static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies, 426 CompressionType compressionType = CompressionType.GZip) { 429 public static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies, CompressionType compressionType = CompressionType.GZip, CancellationToken cancellationToken = default(CancellationToken)) { 427 430 try { 428 431 Serializer serializer = new Serializer(obj, config); 429 432 if (compressionType == CompressionType.Zip) { 430 Serialize(obj, stream, config, includeAssemblies, CompressionLevel.Optimal );433 Serialize(obj, stream, config, includeAssemblies, CompressionLevel.Optimal, cancellationToken); 431 434 } else { 432 Serialize(stream, serializer); 433 } 434 } 435 catch (PersistenceException) { 435 Serialize(stream, serializer, cancellationToken); 436 } 437 } catch (PersistenceException) { 436 438 throw; 437 } 438 catch (Exception e) { 439 } catch (Exception e) { 439 440 throw new PersistenceException("Unexpected exception during Serialization.", e); 440 441 } … … 451 452 /// <param name="compressionType">Type of compression, default is GZip.</param> 452 453 public static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies, out IEnumerable<Type> types, 453 CompressionType compressionType = CompressionType.GZip ) {454 CompressionType compressionType = CompressionType.GZip, CancellationToken cancellationToken = default(CancellationToken)) { 454 455 try { 455 456 Serializer serializer = new Serializer(obj, config); 456 457 if (compressionType == CompressionType.Zip) { 457 Serialize(stream, includeAssemblies, CompressionLevel.Optimal, serializer );458 Serialize(stream, includeAssemblies, CompressionLevel.Optimal, serializer, cancellationToken); 458 459 } else { 459 Serialize(stream, serializer );460 Serialize(stream, serializer, cancellationToken); 460 461 } 461 462 types = serializer.SerializedTypes; 462 } 463 catch (PersistenceException) { 463 } catch (PersistenceException) { 464 464 throw; 465 } 466 catch (Exception e) { 465 } catch (Exception e) { 467 466 throw new PersistenceException("Unexpected exception during Serialization.", e); 468 467 } 469 468 } 470 469 471 private static void Serialize(Stream stream, Serializer serializer) { 470 private static void Serialize(Stream stream, Serializer serializer, CancellationToken cancellationToken = default(CancellationToken)) { 471 cancellationToken.ThrowIfCancellationRequested(); 472 472 using (StreamWriter writer = new StreamWriter(new GZipStream(stream, CompressionMode.Compress))) { 473 473 serializer.InterleaveTypeInformation = true; 474 474 XmlGenerator generator = new XmlGenerator(); 475 475 foreach (ISerializationToken token in serializer) { 476 cancellationToken.ThrowIfCancellationRequested(); 476 477 string line = generator.Format(token); 477 478 writer.Write(line); -
stable/HeuristicLab.Problems.BinPacking
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.BinPacking.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis/3.4
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.GrammaticalEvolution
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.Instances
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.Instances.DataAnalysis
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.Instances.DataAnalysis.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.Instances.TSPLIB.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.QuadraticAssignment
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.QuadraticAssignment.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.TestFunctions
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.TravelingSalesman.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.VehicleRouting
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.VehicleRouting.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Random
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Random (added) merged: 16433 /trunk/HeuristicLab.Random reverse-merged: 16071,16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.Access
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Services.Access (added) merged: 16433 /trunk/HeuristicLab.Services.Access reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.Access.DataAccess
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Services.Access.DataAccess (added) merged: 16433 /trunk/HeuristicLab.Services.Access.DataAccess reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.Deployment
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Services.Deployment (added) merged: 16433 /trunk/HeuristicLab.Services.Deployment reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.Deployment.DataAccess
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Services.Deployment.DataAccess (added) merged: 16433 /trunk/HeuristicLab.Services.Deployment.DataAccess reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.Hive
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.Hive.DataAccess
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.Hive.JanitorService
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Services.Hive.JanitorService (added) merged: 16433 /trunk/HeuristicLab.Services.Hive.JanitorService reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.Hive.Web
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Services.Hive.Web (added) merged: 16433 /trunk/HeuristicLab.Services.Hive.Web reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.OKB
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Services.OKB (added) merged: 16433 /trunk/HeuristicLab.Services.OKB reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.OKB.DataAccess
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Services.OKB.DataAccess (added) merged: 16433 /trunk/HeuristicLab.Services.OKB.DataAccess reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.WebApp
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Services.WebApp (added) merged: 16433 /trunk/HeuristicLab.Services.WebApp reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.WebApp.Maintenance
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Services.WebApp.Maintenance (added) merged: 16433 /trunk/HeuristicLab.Services.WebApp.Maintenance reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.WebApp.Statistics
- Property svn:mergeinfo changed
/branches/2965_CancelablePersistence/HeuristicLab.Services.WebApp.Statistics (added) merged: 16433 /trunk/HeuristicLab.Services.WebApp.Statistics reverse-merged: 16117,16356,16389
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Tests
- Property svn:mergeinfo changed
Note: See TracChangeset
for help on using the changeset viewer.