markus / ConvertService / ServiceBase / Markus.Service.Extensions / Helper / ObjectToStringConvert.cs @ 53c9637d
이력 | 보기 | 이력해설 | 다운로드 (786 Bytes)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
|
7 |
namespace Markus.Service.Helper |
8 |
{ |
9 |
public class ObjectToBytesStringConvert |
10 |
{ |
11 |
public static string ObjectToBytesString(object obj) |
12 |
{ |
13 |
byte[] array = SerializableHelper.Serialize(obj); |
14 |
var compressArray = CompressHelper.Compress(array); |
15 |
|
16 |
return BytesToStringConvert.Base64BytesToString(compressArray); |
17 |
} |
18 |
|
19 |
public static T BytesStringToObject<T>(string s) |
20 |
{ |
21 |
byte[] array = BytesToStringConvert.StringToBase64Bytes(s); |
22 |
var deCompressArray = CompressHelper.Decompress(array); |
23 |
|
24 |
return SerializableHelper.Deserialize<T>(deCompressArray); |
25 |
} |
26 |
} |
27 |
} |