- Timestamp:
- 06/16/15 13:43:03 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlParser.cs
r12012 r12455 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 public static object Deserialize (Stream stream) {224 public 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.