comparison Implab/Xml/SerializationHelpers.cs @ 251:7c7e9ad6fe4a v3

Prerelease version of RunnableComponent Added draft messaging interfaces Added more more helpers to Xml/SerializationHelpers
author cin
date Sun, 11 Feb 2018 00:49:51 +0300
parents 3eaa9372c754
children 3a6e18c432be
comparison
equal deleted inserted replaced
250:9f63dade3a40 251:7c7e9ad6fe4a
36 public static void SerializeToFile<T>(string file, T obj) { 36 public static void SerializeToFile<T>(string file, T obj) {
37 using (var writer = File.CreateText(file)) 37 using (var writer = File.CreateText(file))
38 SerializersPool<T>.Instance.Serialize(writer, obj); 38 SerializersPool<T>.Instance.Serialize(writer, obj);
39 } 39 }
40 40
41 public static void SerializeToElementChild<T>(XmlElement element, T obj) {
42 using(var writer = element.CreateNavigator().AppendChild())
43 SerializersPool<T>.Instance.Serialize(writer, obj);
44 }
45
46 public static T Deserialize<T>(XmlReader reader) {
47 return SerializersPool<T>.Instance.Deserialize(reader);
48 }
49
50 public static T DeserializeFromFile<T>(string file) {
51 using(var reader = XmlReader.Create(File.OpenText(file)))
52 return Deserialize<T>(reader);
53 }
54
41 public static T DeserializeFromString<T>(string data) { 55 public static T DeserializeFromString<T>(string data) {
42 return SerializersPool<T>.Instance.DeserializeFromString(data); 56 return SerializersPool<T>.Instance.DeserializeFromString(data);
43 } 57 }
44 58
45 public static T DeserializeFromXmlNode<T>(XmlNode node) { 59 public static T DeserializeFromXmlNode<T>(XmlNode node) {