NetworkService/LanguageXmlLoader.cs
2022-09-04 08:35:19 +09:00

48 lines
1.1 KiB
C#

using System.Xml;
using System.Xml.Serialization;
using System.IO;
namespace NWService
{
public class LanguageXmlLoader
{
public static string GetPath()
{
return Path.Combine(Directory.GetCurrentDirectory(), "language.xml");
}
public static LanguageXml Load()
{
if (!File.Exists(GetPath()))
{
return default;
}
try
{
Dictionary<string, string> dic = DicSerialize.XmlDeserialize<string, string>(GetPath());
return new LanguageXml()
{
messageMaps = dic
};
}
catch(Exception e)
{
Console.WriteLine(e);
return default;
}
}
public static void Save(LanguageXml xml)
{
try
{
DicSerialize.XmlSerialize<string, string>(GetPath(), xml.messageMaps);
}
catch(Exception e)
{
Console.WriteLine(e);
}
}
}
}