59 lines
1.4 KiB
C#
Raw Normal View History

2025-06-07 17:43:34 +08:00
using System.Collections.Generic;
using System.Xml;
public class ConfigUtils
{
private static Dictionary<string, string> m_config = new Dictionary<string, string>();
public static void SetXmlData(string xmlData)
{
m_config.Clear();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlData);
XmlNodeList nodeList = xmlDoc.SelectSingleNode("config").ChildNodes;
foreach (XmlElement xe in nodeList)
{
m_config[xe.Name] = xe.InnerText;
}
}
//根据key获取远程配置数据
public static string GetConfig(string key)
{
if (m_config.ContainsKey(key))
return m_config[key];
return "";
}
public static string GetServerVersion()
{
string remoteVersion = GetConfig("version");
return remoteVersion;
}
public static string[] GetVersionList()
{
string remoteVersion = GetConfig("versionList");
if (string.IsNullOrEmpty(remoteVersion))
{
return null;
}
return remoteVersion.Split(',');
}
//是否启动热更逻辑
public static bool IsUpdateModel()
{
string str = GetConfig("UpdateMode");
return str == "1";
}
//获取热更时的web地址
public static string GetWebUrl()
{
string str = GetConfig("WebUrl");
return str;
}
}