36 lines
883 B
C#
36 lines
883 B
C#
using BS.SharedLauncher.DataContract;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace BS.SharedLauncher.Logic
|
|
{
|
|
public static class XmlConverter
|
|
{
|
|
public static string Serialize<T>(T obj)
|
|
where T : class
|
|
{
|
|
XmlSerializer ser = new XmlSerializer(typeof(T));
|
|
|
|
using (StringWriter sw = new StringWriter())
|
|
{
|
|
ser.Serialize(sw, obj);
|
|
return sw.ToString();
|
|
}
|
|
}
|
|
|
|
public static T Deserialize<T>(string input)
|
|
where T : class
|
|
{
|
|
XmlSerializer ser = new XmlSerializer(typeof(T));
|
|
|
|
using (StringReader sr = new StringReader(input))
|
|
return (T)ser.Deserialize(sr);
|
|
}
|
|
}
|
|
}
|