comparison Implab/Xml/SerializationHelpers.cs @ 231:3eaa9372c754 v2

Added SerializationHelpers.SerializeToFile method
author cin
date Thu, 21 Sep 2017 01:06:32 +0300
parents 5f7a3e1d32b9
children 7c7e9ad6fe4a
comparison
equal deleted inserted replaced
229:5f7a3e1d32b9 231:3eaa9372c754
1 using System; 1 using System;
2 using System.Collections.Generic; 2 using System.Collections.Generic;
3 using System.IO;
3 using System.Linq; 4 using System.Linq;
4 using System.Text; 5 using System.Text;
5 using System.Threading.Tasks; 6 using System.Threading.Tasks;
6 using System.Xml; 7 using System.Xml;
7 using System.Xml.Linq; 8 using System.Xml.Linq;
30 SerializersPool<T>.Instance.Serialize(writer, obj); 31 SerializersPool<T>.Instance.Serialize(writer, obj);
31 } 32 }
32 return doc; 33 return doc;
33 } 34 }
34 35
36 public static void SerializeToFile<T>(string file, T obj) {
37 using (var writer = File.CreateText(file))
38 SerializersPool<T>.Instance.Serialize(writer, obj);
39 }
40
35 public static T DeserializeFromString<T>(string data) { 41 public static T DeserializeFromString<T>(string data) {
36 return SerializersPool<T>.Instance.DeserializeFromString(data); 42 return SerializersPool<T>.Instance.DeserializeFromString(data);
37 } 43 }
38 44
39 public static T DeserializeFromXmlNode<T>(XmlNode node) { 45 public static T DeserializeFromXmlNode<T>(XmlNode node) {