Changeset 12467 for branches/HiveStatistics/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlParser.cs
- Timestamp:
- 06/18/15 11:56:31 (9 years ago)
- Location:
- branches/HiveStatistics/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources
- Property svn:mergeinfo changed
/trunk/sources (added) merged: 12442-12443,12445,12455-12458,12461,12463-12465 -
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:mergeinfo changed
-
branches/HiveStatistics/sources/HeuristicLab.Persistence
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Persistence (added) merged: 12455-12456
- Property svn:mergeinfo changed
-
branches/HiveStatistics/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlParser.cs
r12012 r12467 218 218 219 219 /// <summary> 220 /// Deserializes an object from the specified stream .220 /// Deserializes an object from the specified stream using GZip compression. 221 221 /// </summary> 222 222 /// <param name="stream">The stream.</param> 223 223 /// <returns>A fresh object instance.</returns> 224 p ublic static object Deserialize(Stream stream) {224 private static object DeserializeWithGZip(Stream stream) { 225 225 try { 226 226 using (StreamReader reader = new StreamReader(new GZipStream(stream, CompressionMode.Decompress))) { … … 239 239 240 240 /// <summary> 241 /// Deserializes an object from the specified stream using Zip compression. 242 /// </summary> 243 /// <param name="stream">The stream.</param> 244 /// <returns>A fresh object instance.</returns> 245 private static object DeserializeWithZip(Stream stream) { 246 ZipArchive zipFile = new ZipArchive(stream); 247 return Deserialize(zipFile); 248 } 249 250 /// <summary> 241 251 /// Deserializes an object from the specified stream. 242 252 /// </summary> 243 253 /// <typeparam name="T">object type expected from the serialized stream</typeparam> 244 254 /// <param name="stream">The stream.</param> 255 /// <param name="useZip">If true, uses zip for decompression, otherwise gzip.</param> 245 256 /// <returns>A fresh object instance.</returns> 246 public static T Deserialize<T>(Stream stream) { 247 return (T)Deserialize(stream); 257 public static T Deserialize<T>(Stream stream, bool useZip = false) { 258 return (T)Deserialize(stream, useZip); 259 } 260 261 /// <summary> 262 /// Deserializes an object from the specified stream. 263 /// </summary> 264 /// <param name="stream">The stream.</param> 265 /// <param name="useZip">If true, uses zip for decompression, otherwise gzip.</param> 266 /// <returns>A fresh object instance.</returns> 267 public static object Deserialize(Stream stream, bool useZip = false) { 268 if (useZip) { 269 return DeserializeWithZip(stream); 270 } else { 271 return DeserializeWithGZip(stream); 272 } 248 273 } 249 274
Note: See TracChangeset
for help on using the changeset viewer.