21 lines
563 B
C#
21 lines
563 B
C#
using System.Xml.Serialization;
|
|
|
|
namespace CloudBuilder.Util
|
|
{
|
|
public class DeserializeHelper<T>
|
|
{
|
|
public static T Deserialize(string xml)
|
|
{
|
|
StringReader textReader = new StringReader(xml);
|
|
XmlSerializer serializer = new XmlSerializer(typeof(T));
|
|
return (T)serializer.Deserialize(textReader);
|
|
}
|
|
|
|
public static string LoadXml(string filePath)
|
|
{
|
|
if (!File.Exists(filePath)) return null;
|
|
return File.ReadAllText(Path.Combine(filePath));
|
|
}
|
|
}
|
|
}
|