mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-11-27 10:06:53 -08:00
19 lines
583 B
C#
19 lines
583 B
C#
using System.Xml.Serialization;
|
|
|
|
namespace sodoff.Util;
|
|
public class XmlUtil {
|
|
public static T DeserializeXml<T>(string xmlString) {
|
|
var serializer = new XmlSerializer(typeof(T));
|
|
using (var reader = new StringReader(xmlString))
|
|
return (T)serializer.Deserialize(reader);
|
|
}
|
|
|
|
public static string SerializeXml<T>(T xmlObject) {
|
|
var serializer = new XmlSerializer(typeof(T));
|
|
using (var writer = new StringWriter()) {
|
|
serializer.Serialize(writer, xmlObject);
|
|
return writer.ToString();
|
|
}
|
|
}
|
|
}
|