- Timestamp:
- 05/04/17 17:19:35 (8 years ago)
- Location:
- branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/Compact/ByteArray2XmlSerializer.cs
r14185 r14927 36 36 internal sealed class Bytet2DArray2XmlSerializer : ByteArray2XmlSerializer<byte[,]> { } 37 37 38 internal sealed class Byte3DArray2XmlSerializer : ByteArray2XmlSerializer<byte[, 38 internal sealed class Byte3DArray2XmlSerializer : ByteArray2XmlSerializer<byte[,,]> { } 39 39 } -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/Compact/DoubleArray2XmlSerializer.cs
r14185 r14927 39 39 internal sealed class Double2DArray2XmlSerializer : DoubleArray2XmlSerializerBase<double[,]> { } 40 40 41 internal sealed class Double3DArray2XmlSerializer : DoubleArray2XmlSerializerBase<double[, 41 internal sealed class Double3DArray2XmlSerializer : DoubleArray2XmlSerializerBase<double[,,]> { } 42 42 43 43 } -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/Compact/DoubleList2XmlSerializer.cs
r14185 r14927 46 46 } 47 47 return list; 48 } 49 catch (InvalidCastException e) { 48 } catch (InvalidCastException e) { 50 49 throw new PersistenceException("Invalid element data during reconstruction of List<double>.", e); 51 } 52 catch (OverflowException e) { 50 } catch (OverflowException e) { 53 51 throw new PersistenceException("Overflow during element parsing while trying to reconstruct List<double>.", e); 54 52 } -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/Compact/IntArray2XmlSerializer.cs
r14185 r14927 38 38 internal class Int2DArray2XmlSerializer : IntArray2XmlSerializerBase<int[,]> { } 39 39 40 internal class Int3DArray2XmlSerializer : IntArray2XmlSerializerBase<int[, 40 internal class Int3DArray2XmlSerializer : IntArray2XmlSerializerBase<int[,,]> { } 41 41 42 42 } -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/Compact/NumberArray2XmlSerializerBase.cs
r14185 r14927 27 27 using HeuristicLab.Persistence.Auxiliary; 28 28 using HeuristicLab.Persistence.Core; 29 using HeuristicLab.Persistence .Default.CompositeSerializers.Storable;29 using HeuristicLab.Persistence; 30 30 31 31 namespace HeuristicLab.Persistence.Default.Xml.Compact { 32 32 33 [Storable Class]33 [StorableType("ed511bc6-4889-4be1-bb57-c819d3e9e7be")] 34 34 internal abstract class NumberArray2XmlSerializerBase<T> : CompactXmlSerializerBase<T> where T : class { 35 35 … … 108 108 throw new PersistenceException("Insufficient number of elements while trying to fill number array."); 109 109 return (T)(object)a; 110 } 111 catch (InvalidOperationException e) { 110 } catch (InvalidOperationException e) { 112 111 throw new PersistenceException("Insufficient information to rebuild number array.", e); 113 } 114 catch (InvalidCastException e) { 112 } catch (InvalidCastException e) { 115 113 throw new PersistenceException("Invalid element data or meta data to reconstruct number array.", e); 116 } 117 catch (OverflowException e) { 114 } catch (OverflowException e) { 118 115 throw new PersistenceException("Overflow during element parsing while trying to reconstruct number array.", e); 119 116 } -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/Compact/NumberEnumeration2XmlSerializerBase.cs
r14185 r14927 25 25 using HeuristicLab.Persistence.Auxiliary; 26 26 using HeuristicLab.Persistence.Core; 27 using HeuristicLab.Persistence .Default.CompositeSerializers.Storable;27 using HeuristicLab.Persistence; 28 28 29 29 namespace HeuristicLab.Persistence.Default.Xml.Compact { 30 30 31 [Storable Class]31 [StorableType("a0910e86-de41-4862-abf5-82bbed54de70")] 32 32 internal abstract class NumberEnumeration2XmlSerializerBase<T> : CompactXmlSerializerBase<T> where T : IEnumerable { 33 33 … … 54 54 } 55 55 return (T)enumeration; 56 } 57 catch (InvalidCastException e) { 56 } catch (InvalidCastException e) { 58 57 throw new PersistenceException("Invalid element data during reconstruction of number enumerable.", e); 59 } 60 catch (OverflowException e) { 58 } catch (OverflowException e) { 61 59 throw new PersistenceException("Overflow during element parsing while trying to reconstruct number enumerable.", e); 62 60 } -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/EasyXmlGenerator.cs
r14185 r14927 154 154 File.Copy(tempfile, filename, true); 155 155 File.Delete(tempfile); 156 } 157 catch (Exception) { 156 } catch (Exception) { 158 157 Logger.Warn("Exception caught, no data has been written."); 159 158 throw; … … 181 180 try { 182 181 using (StreamWriter writer = new StreamWriter(stream)) { 183 Serializer serializer = newSerializer(obj, config);182 var serializer = new HeuristicLab.Persistence.Core.Serializer(obj, config); 184 183 serializer.InterleaveTypeInformation = true; 185 184 ReadableXmlGenerator generator = new ReadableXmlGenerator(); … … 190 189 writer.Flush(); 191 190 } 192 } 193 catch (PersistenceException) { 191 } catch (PersistenceException) { 194 192 throw; 195 } 196 catch (Exception e) { 193 } catch (Exception e) { 197 194 throw new PersistenceException("Unexpected exception during Serialization.", e); 198 195 } -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/Char2XmlFormatter.cs
r14185 r14927 37 37 38 38 private static string ToBase64String(char c) { 39 return string.Format("<Base64>{0}</Base64>", Convert.ToBase64String(Encoding.ASCII.GetBytes(new[] { c})));39 return string.Format("<Base64>{0}</Base64>", Convert.ToBase64String(Encoding.ASCII.GetBytes(new[] { c }))); 40 40 } 41 41 -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/DateTime2XmlSerializer.cs
r14185 r14927 34 34 try { 35 35 return new DateTime(long.Parse(x.Data)); 36 } 37 catch (Exception e) { 36 } catch (Exception e) { 38 37 throw new PersistenceException("Exception caugth while trying to reconstruct DateTime object.", e); 39 38 } -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/Guid2XmlSerializer.cs
r14185 r14927 36 36 try { 37 37 return new Guid(t.Data); 38 } 39 catch (FormatException x) { 38 } catch (FormatException x) { 40 39 throw new PersistenceException("Cannot parse Guid string representation.", x); 41 } 42 catch (OverflowException x) { 40 } catch (OverflowException x) { 43 41 throw new PersistenceException("Overflow during Guid parsing.", x); 44 42 } -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/SimpleNumber2XmlSerializerBase.cs
r14185 r14927 44 44 try { 45 45 return (T)ParseMethod.Invoke(null, new[] { x.Data }); 46 } 47 catch (Exception e) { 46 } catch (Exception e) { 48 47 throw new PersistenceException("Could not parse simple number.", e); 49 48 } -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/System.Drawing/Bitmap2XmlSerializer.cs
r14185 r14927 28 28 internal sealed class Bitmap2XmlSerializer : PrimitiveXmlSerializerBase<Bitmap> { 29 29 30 public override XmlString Format(Bitmap o) { 30 public override XmlString Format(Bitmap o) { 31 31 MemoryStream stream = new MemoryStream(); 32 32 lock (o) -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/TimeSpan2XmlSerializer.cs
r14185 r14927 35 35 try { 36 36 return TimeSpan.Parse(t.Data); 37 } 38 catch (FormatException x) { 37 } catch (FormatException x) { 39 38 throw new PersistenceException("Cannot parse TimeSpan string representation.", x); 40 } 41 catch (OverflowException x) { 39 } catch (OverflowException x) { 42 40 throw new PersistenceException("Overflow during TimeSpan parsing.", x); 43 41 } -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/XmlFormat.cs
r14185 r14927 20 20 #endregion 21 21 22 using HeuristicLab.Persistence .Default.CompositeSerializers.Storable;22 using HeuristicLab.Persistence; 23 23 using HeuristicLab.Persistence.Interfaces; 24 24 … … 29 29 /// or save to a file. 30 30 /// </summary> 31 [Storable Class]31 [StorableType("8c79e9a6-02d6-471c-8787-43d96d61c1db")] 32 32 public class XmlFormat : FormatBase<XmlString> { 33 33 /// <summary> -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs
r14185 r14927 61 61 } 62 62 63 protected enum NodeType { Start, End, Inline } 63 protected enum NodeType { Start, End, Inline }; 64 64 65 65 protected static void AddXmlTagContent(StringBuilder sb, string name, Dictionary<string, string> attributes) { … … 256 256 {"typeName", lastTypeToken.TypeName }, 257 257 {"serializer", lastTypeToken.Serializer }}); 258 } 259 finally { 258 } finally { 260 259 lastTypeToken = null; 261 260 } … … 313 312 private static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies 314 313 , CompressionLevel compression) { 315 Serializer serializer = newSerializer(obj, config);314 var serializer = new HeuristicLab.Persistence.Core.Serializer(obj, config); 316 315 Serialize(stream, includeAssemblies, compression, serializer); 317 316 } 318 317 319 private static void Serialize(Stream stream, bool includeAssemblies, CompressionLevel compression, Serializer serializer) {318 private static void Serialize(Stream stream, bool includeAssemblies, CompressionLevel compression, HeuristicLab.Persistence.Core.Serializer serializer) { 320 319 try { 321 320 DateTime start = DateTime.Now; … … 360 359 Logger.Info(String.Format("serialization took {0} seconds with compression level {1}", 361 360 (DateTime.Now - start).TotalSeconds, compression)); 362 } 363 catch (Exception) { 361 } catch (Exception) { 364 362 Logger.Warn("Exception caught, no data has been serialized."); 365 363 throw; … … 385 383 File.Copy(tempfile, filename, true); 386 384 File.Delete(tempfile); 387 } 388 catch (Exception) { 385 } catch (Exception) { 389 386 Logger.Warn("Exception caught, no data has been written."); 390 387 throw; … … 426 423 CompressionType compressionType = CompressionType.GZip) { 427 424 try { 428 Serializer serializer = newSerializer(obj, config);425 var serializer = new HeuristicLab.Persistence.Core.Serializer(obj, config); 429 426 if (compressionType == CompressionType.Zip) { 430 427 Serialize(obj, stream, config, includeAssemblies, CompressionLevel.Optimal); … … 432 429 Serialize(stream, serializer); 433 430 } 434 } 435 catch (PersistenceException) { 431 } catch (PersistenceException) { 436 432 throw; 437 } 438 catch (Exception e) { 433 } catch (Exception e) { 439 434 throw new PersistenceException("Unexpected exception during Serialization.", e); 440 435 } … … 453 448 CompressionType compressionType = CompressionType.GZip) { 454 449 try { 455 Serializer serializer = newSerializer(obj, config);450 var serializer = new HeuristicLab.Persistence.Core.Serializer(obj, config); 456 451 if (compressionType == CompressionType.Zip) { 457 452 Serialize(stream, includeAssemblies, CompressionLevel.Optimal, serializer); … … 460 455 } 461 456 types = serializer.SerializedTypes; 462 } 463 catch (PersistenceException) { 457 } catch (PersistenceException) { 464 458 throw; 465 } 466 catch (Exception e) { 459 } catch (Exception e) { 467 460 throw new PersistenceException("Unexpected exception during Serialization.", e); 468 461 } 469 462 } 470 463 471 private static void Serialize(Stream stream, Serializer serializer) {464 private static void Serialize(Stream stream, HeuristicLab.Persistence.Core.Serializer serializer) { 472 465 using (StreamWriter writer = new StreamWriter(new GZipStream(stream, CompressionMode.Compress))) { 473 466 serializer.InterleaveTypeInformation = true; -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/XmlParser.cs
r14185 r14927 81 81 try { 82 82 iterator = handlers[reader.Name].Invoke(); 83 } 84 catch (KeyNotFoundException) { 83 } catch (KeyNotFoundException) { 85 84 throw new PersistenceException(String.Format( 86 85 "Invalid XML tag \"{0}\" in persistence file.", … … 182 181 } 183 182 return typeCache; 184 } 185 catch (PersistenceException) { 183 } catch (PersistenceException) { 186 184 throw; 187 } 188 catch (Exception e) { 185 } catch (Exception e) { 189 186 throw new PersistenceException("Unexpected exception during type cache parsing.", e); 190 187 } … … 204 201 } 205 202 } 206 } 207 finally { 203 } finally { 208 204 TimeSpan end = System.Diagnostics.Process.GetCurrentProcess().TotalProcessorTime; 209 205 Tracing.Logger.Info(string.Format( … … 251 247 return deserializer.Deserialize(parser); 252 248 } 253 } 254 catch (PersistenceException) { 249 } catch (PersistenceException) { 255 250 throw; 256 } 257 catch (Exception x) { 251 } catch (Exception x) { 258 252 throw new PersistenceException("Unexpected exception during deserialization", x); 259 253 } … … 279 273 280 274 return result; 281 } 282 catch (PersistenceException) { 275 } catch (PersistenceException) { 283 276 throw; 284 } 285 catch (Exception e) { 277 } catch (Exception e) { 286 278 throw new PersistenceException("Unexpected exception during deserialization", e); 287 279 } -
branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/Xml/XmlString.cs
r14185 r14927 21 21 22 22 using System.Text; 23 using HeuristicLab.Persistence .Default.CompositeSerializers.Storable;23 using HeuristicLab.Persistence; 24 24 using HeuristicLab.Persistence.Interfaces; 25 25 … … 29 29 /// XML friendly encapsulation of string data. 30 30 /// </summary> 31 [Storable Class]31 [StorableType("a358bb95-a494-4512-b1fe-53c66c77423c")] 32 32 public class XmlString : ISerialData { 33 33
Note: See TracChangeset
for help on using the changeset viewer.