mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
38 lines
1 KiB
C#
38 lines
1 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.IO;
|
|||
|
using System.Xml.Serialization;
|
|||
|
|
|||
|
namespace RimWorldAnimationStudio
|
|||
|
{
|
|||
|
public class XmlUtility
|
|||
|
{
|
|||
|
public T ReadXML<T>(string path)
|
|||
|
{
|
|||
|
using (StreamReader stringReader = new StreamReader(path))
|
|||
|
{
|
|||
|
XmlSerializer serializer = new XmlSerializer(typeof(T));
|
|||
|
|
|||
|
return (T)serializer.Deserialize(stringReader);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void WriteXML(AnimationDef animationDef, string path)
|
|||
|
{
|
|||
|
if (animationDef == null || path == null || path == "")
|
|||
|
{ return; }
|
|||
|
|
|||
|
XmlSerializer writer = new XmlSerializer(typeof(AnimationDef));
|
|||
|
XmlSerializerNamespaces nameSpaces = new XmlSerializerNamespaces();
|
|||
|
nameSpaces.Add("", "");
|
|||
|
|
|||
|
FileStream file = File.Create(path);
|
|||
|
writer.Serialize(file, animationDef, nameSpaces);
|
|||
|
file.Close();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|