- Timestamp:
- 06/02/16 12:35:30 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive/3.3/Util/PersistenceUtil.cs
r12012 r13871 20 20 #endregion 21 21 22 using HeuristicLab.Persistence.Core; 23 using HeuristicLab.Persistence.Default.Xml; 22 24 using System; 23 25 using System.Collections.Generic; 24 26 using System.IO; 25 using HeuristicLab.Persistence.Core;26 using HeuristicLab.Persistence.Default.Xml;27 27 28 namespace HeuristicLab.Clients.Hive { 29 public static class PersistenceUtil { 30 public static byte[] Serialize(object obj, out IEnumerable<Type> types) { 31 using (MemoryStream memStream = new MemoryStream()) { 32 XmlGenerator.Serialize(obj, memStream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, out types); 33 byte[] jobByteArray = memStream.ToArray(); 34 return jobByteArray; 35 } 28 namespace HeuristicLab.Clients.Hive 29 { 30 public static class PersistenceUtil 31 { 32 public static byte[] Serialize(object obj, out IEnumerable<Type> types) 33 { 34 using (MemoryStream memStream = new MemoryStream()) 35 { 36 XmlGenerator.Serialize(obj, memStream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, out types); 37 byte[] jobByteArray = memStream.ToArray(); 38 return jobByteArray; 39 } 40 } 41 42 public static byte[] Serialize(object obj) 43 { 44 using (MemoryStream memStream = new MemoryStream()) 45 { 46 XmlGenerator.Serialize(obj, memStream); 47 byte[] jobByteArray = memStream.ToArray(); 48 return jobByteArray; 49 } 50 } 51 52 public static T Deserialize<T>(byte[] sjob) 53 { 54 using (MemoryStream memStream = new MemoryStream(sjob)) 55 { 56 T job = XmlParser.Deserialize<T>(memStream, CompressionType.Zip); 57 return job; 58 } 59 } 36 60 } 37 38 public static byte[] Serialize(object obj) {39 using (MemoryStream memStream = new MemoryStream()) {40 XmlGenerator.Serialize(obj, memStream);41 byte[] jobByteArray = memStream.ToArray();42 return jobByteArray;43 }44 }45 46 public static T Deserialize<T>(byte[] sjob) {47 using (MemoryStream memStream = new MemoryStream(sjob)) {48 T job = XmlParser.Deserialize<T>(memStream);49 return job;50 }51 }52 }53 61 }
Note: See TracChangeset
for help on using the changeset viewer.