##// END OF EJS Templates
Added IInitializable.Initialize() overload...
Added IInitializable.Initialize() overload Added IRunnable.Start(), IRunnable.Start() overloads Fixed cancellation of the current operation when Stop() is called More tests

File last commit:

r251:7c7e9ad6fe4a v3
r262:f1696cdc3d7a v3.0.8 v3
Show More
SerializationHelpers.cs
65 lines | 2.3 KiB | text/x-csharp | CSharpLexer
/ Implab / Xml / SerializationHelpers.cs
cin
JsonXmlReader performance tuning...
r229 using System;
using System.Collections.Generic;
cin
Added SerializationHelpers.SerializeToFile method
r231 using System.IO;
cin
JsonXmlReader performance tuning...
r229 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;
}
cin
Added SerializationHelpers.SerializeToFile method
r231 public static void SerializeToFile<T>(string file, T obj) {
using (var writer = File.CreateText(file))
SerializersPool<T>.Instance.Serialize(writer, obj);
}
cin
Prerelease version of RunnableComponent...
r251 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);
}
cin
JsonXmlReader performance tuning...
r229 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);
}
}
}