2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
|
|
|
|
|
///
|
|
|
|
|
|
using System.IO;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF.Tools
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class XmlTools
|
|
|
|
|
|
{
|
|
|
|
|
|
public static string ToXmlString<T>(this T input)
|
|
|
|
|
|
{
|
|
|
|
|
|
using (var writer = new StringWriter())
|
|
|
|
|
|
{
|
|
|
|
|
|
input.ToXml(writer);
|
|
|
|
|
|
return writer.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void ToXml<T>(this T objectToSerialize, Stream stream)
|
|
|
|
|
|
{
|
|
|
|
|
|
new XmlSerializer(typeof(T)).Serialize(stream, objectToSerialize);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void ToXml<T>(this T objectToSerialize, StringWriter writer)
|
|
|
|
|
|
{
|
|
|
|
|
|
new XmlSerializer(typeof(T)).Serialize(writer, objectToSerialize);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|