Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/02/16 12:35:30 (8 years ago)
Author:
jlodewyc
Message:

#2582 final commit / end of internship

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/WebJobManager/HeuristicLab.Clients.Hive/3.3/Util/PersistenceUtil.cs

    r12012 r13871  
    2020#endregion
    2121
     22using HeuristicLab.Persistence.Core;
     23using HeuristicLab.Persistence.Default.Xml;
    2224using System;
    2325using System.Collections.Generic;
    2426using System.IO;
    25 using HeuristicLab.Persistence.Core;
    26 using HeuristicLab.Persistence.Default.Xml;
    2727
    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       }
     28namespace 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        }
    3660    }
    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   }
    5361}
Note: See TracChangeset for help on using the changeset viewer.