Mercurial > pub > ImplabNet
diff 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 |
line wrap: on
line diff
--- a/Implab/Xml/SerializationHelpers.cs Thu Feb 01 02:43:35 2018 +0300 +++ b/Implab/Xml/SerializationHelpers.cs Sun Feb 11 00:49:51 2018 +0300 @@ -38,6 +38,20 @@ SerializersPool<T>.Instance.Serialize(writer, obj); } + public static void SerializeToElementChild<T>(XmlElement element, T obj) { + using(var writer = element.CreateNavigator().AppendChild()) + SerializersPool<T>.Instance.Serialize(writer, obj); + } + + public static T Deserialize<T>(XmlReader reader) { + return SerializersPool<T>.Instance.Deserialize(reader); + } + + public static T DeserializeFromFile<T>(string file) { + using(var reader = XmlReader.Create(File.OpenText(file))) + return Deserialize<T>(reader); + } + public static T DeserializeFromString<T>(string data) { return SerializersPool<T>.Instance.DeserializeFromString(data); }