##// END OF EJS Templates
JsonXmlReader performance tuning...
JsonXmlReader performance tuning JsonScanner now operates strings and doesn't parses number and literals. Added SerializationHelpers to common serialize/deserialize operations

File last commit:

r229:5f7a3e1d32b9 v2
r229:5f7a3e1d32b9 v2
Show More
SerializationHelpers.cs
45 lines | 1.5 KiB | text/x-csharp | CSharpLexer
/ Implab / Xml / SerializationHelpers.cs
cin
JsonXmlReader performance tuning...
r229 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
namespace Implab.Xml {
public static class SerializationHelpers {
public static string SerializeAsString<T>(T obj) {
return SerializersPool<T>.Instance.SerializeAsString(obj);
}
public static void Serialize<T>(XmlWriter writer, T obj) {
SerializersPool<T>.Instance.Serialize(writer, obj);
}
public static XmlDocument SerializeAsXmlDocument<T>(T obj) {
var doc = new XmlDocument();
using (var writer = doc.CreateNavigator().AppendChild()) {
SerializersPool<T>.Instance.Serialize(writer, obj);
}
return doc;
}
public static XDocument SerializeAsXDocument<T>(T obj) {
var doc = new XDocument();
using (var writer = doc.CreateWriter()) {
SerializersPool<T>.Instance.Serialize(writer, obj);
}
return doc;
}
public static T DeserializeFromString<T>(string data) {
return SerializersPool<T>.Instance.DeserializeFromString(data);
}
public static T DeserializeFromXmlNode<T>(XmlNode node) {
Safe.ArgumentNotNull(node, nameof(node));
using (var reader = node.CreateNavigator().ReadSubtree())
return SerializersPool<T>.Instance.Deserialize(reader);
}
}
}