XML 示例文件
<?xml version="1.0"?>
<Envs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Xmpp ServiceKey="XMPPHost" Path="https://xxx.com" Remark="通讯服务器地址" />
<XmppDomain ServiceKey="XMPPDomain" Path="https://xxx.com" Remark="通讯服务器虚拟地址" />
<Api ServiceKey="apiUrl" Path="https://xxx.com" Remark="API接口地址" />
<Video ServiceKey="jitsiServer" Path="https://xxx.com" Remark="视频服务器地址" />
<Mall ServiceKey="mallServerUrl" Path="" Remark="商城地址" />
<LiveBroadcast ServiceKey="liveUrl" Path="rtmp://xxx/live/" Remark="直播地址" />
<FileUpload ServiceKey="uploadUrl" Path="https://xxx.com" Remark="文件上传地址" />
<FileDownload ServiceKey="downloadUrl" Path="https://xxx.com" Remark="文件下载地址" />
<FileDownloadHead ServiceKey="downloadAvatarUrl" Path="http://bpm.yangzijiang.com" Remark="头像下载地址" />
<AppUpdate ServiceKey="" Path="http://xxx/packages/Huyouzhijia_win.msi" Remark="程序更新地址" />
<AppConfig ServiceKey="" Path="http://xxx/packages/updata.xml" Remark="配置文件地址" />
<Env>
<EnvConfig Name="Dev" Remark="开发环境">
<Xmpp ServiceKey="XMPPHost" Path="https://xxx.com" Remark="通讯服务器地址" />
<XmppDomain ServiceKey="XMPPDomain" Path="https://xxx.com" Remark="通讯服务器虚拟地址" />
<Api ServiceKey="apiUrl" Path="https://xxx.com" Remark="API接口地址" />
<Video ServiceKey="jitsiServer" Path="https://xxx.com" Remark="视频服务器地址" />
<Mall ServiceKey="mallServerUrl" Path="" Remark="商城地址" />
<LiveBroadcast ServiceKey="liveUrl" Path="rtmp://xxx/live/" Remark="直播地址" />
<FileUpload ServiceKey="uploadUrl" Path="https://xxx.com" Remark="文件上传地址" />
<FileDownload ServiceKey="downloadUrl" Path="https://xxx.com" Remark="文件下载地址" />
<FileDownloadHead ServiceKey="downloadAvatarUrl" Path="http://bpm.yangzijiang.com" Remark="头像下载地址" />
<AppUpdate ServiceKey="" Path="http://xxx/packages/Huyouzhijia_win.msi" Remark="程序更新地址" />
<AppConfig ServiceKey="" Path="http://xxx/packages/updata.xml" Remark="配置文件地址" />
</EnvConfig>
<EnvConfig Name="Uat" Remark="堡垒环境">
<Xmpp ServiceKey="XMPPHost" Path="https://xxx.com" Remark="通讯服务器地址" />
<XmppDomain ServiceKey="XMPPDomain" Path="https://xxx.com" Remark="通讯服务器虚拟地址" />
<Api ServiceKey="apiUrl" Path="https://xxx.com" Remark="API接口地址" />
<Video ServiceKey="jitsiServer" Path="https://xxx.com" Remark="视频服务器地址" />
<Mall ServiceKey="mallServerUrl" Path="" Remark="商城地址" />
<LiveBroadcast ServiceKey="liveUrl" Path="rtmp://xxx/live/" Remark="直播地址" />
<FileUpload ServiceKey="uploadUrl" Path="https://xxx.com" Remark="文件上传地址" />
<FileDownload ServiceKey="downloadUrl" Path="https://xxx.com" Remark="文件下载地址" />
<FileDownloadHead ServiceKey="downloadAvatarUrl" Path="http://bpm.yangzijiang.com" Remark="头像下载地址" />
<AppUpdate ServiceKey="" Path="http://xxx/packages/Huyouzhijia_win.msi" Remark="程序更新地址" />
<AppConfig ServiceKey="" Path="http://xxx/packages/updata.xml" Remark="配置文件地址" />
</EnvConfig>
<EnvConfig Name="Drp" Remark="产出环境">
<Xmpp ServiceKey="XMPPHost" Path="https://xxx.com" Remark="通讯服务器地址" />
<XmppDomain ServiceKey="XMPPDomain" Path="https://xxx.com" Remark="通讯服务器虚拟地址" />
<Api ServiceKey="apiUrl" Path="https://xxx.com" Remark="API接口地址" />
<Video ServiceKey="jitsiServer" Path="https://xxx.com" Remark="视频服务器地址" />
<Mall ServiceKey="mallServerUrl" Path="" Remark="商城地址" />
<LiveBroadcast ServiceKey="liveUrl" Path="rtmp://xxx/live/" Remark="直播地址" />
<FileUpload ServiceKey="uploadUrl" Path="https://xxx.com" Remark="文件上传地址" />
<FileDownload ServiceKey="downloadUrl" Path="https://xxx.com" Remark="文件下载地址" />
<FileDownloadHead ServiceKey="downloadAvatarUrl" Path="http://bpm.yangzijiang.com" Remark="头像下载地址" />
<AppUpdate ServiceKey="" Path="http://xxx/packages/Huyouzhijia_win.msi" Remark="程序更新地址" />
<AppConfig ServiceKey="" Path="http://xxx/packages/updata.xml" Remark="配置文件地址" />
</EnvConfig>
</Env>
<Nodes>
<NodeItemConfig Key="Xmpp" ServiceKey="XMPPHost" Path="https://xxx.com" Remark="通讯服务器地址" />
<NodeItemConfig Key="XmppDomain" ServiceKey="XMPPDomain" Path="https://xxx.com" Remark="通讯服务器虚拟地址" />
<NodeItemConfig Key="Api" ServiceKey="apiUrl" Path="https://xxx.com" Remark="API接口地址" />
<NodeItemConfig Key="Video" ServiceKey="jitsiServer" Path="https://xxx.com" Remark="视频服务器地址" />
<NodeItemConfig Key="Mall" ServiceKey="mallServerUrl" Path="" Remark="商城地址" />
<NodeItemConfig Key="LiveBroadcast" ServiceKey="liveUrl" Path="rtmp://xxx/live/" Remark="直播地址" />
<NodeItemConfig Key="FileUpload" ServiceKey="uploadUrl" Path="https://xxx.com" Remark="文件上传地址" />
<NodeItemConfig Key="FileDownload" ServiceKey="downloadUrl" Path="https://xxx.com" Remark="文件下载地址" />
<NodeItemConfig Key="FileDownloadHead" ServiceKey="downloadAvatarUrl" Path="http://bpm.yangzijiang.com" Remark="头像下载地址" />
<NodeItemConfig Key="AppUpdate" ServiceKey="" Path="http://xxx/packages/Huyouzhijia_win.msi" Remark="程序更新地址" />
<NodeItemConfig Key="AppConfig" ServiceKey="" Path="http://xxx/packages/updata.xml" Remark="配置文件地址" />
</Nodes>
</Envs>
XML对应实体类
/// <summary>
/// 节点属性
/// </summary>
public class NodeProp
{
public NodeProp()
{
}
public NodeProp(string path)
{
Path = path;
}
public NodeProp(string serviceKey, string path)
{
ServiceKey = serviceKey;
Path = path;
}
public NodeProp(string serviceKey, string path, string remark)
{
ServiceKey = serviceKey;
Path = path;
Remark = remark;
}
public NodeProp(string key, string serviceKey, string path, string remark)
{
Key = key;
ServiceKey = serviceKey;
Path = path;
Remark = remark;
}
/// <summary>
/// 唯一ID
/// </summary>
[XmlAttribute("Key")]
public string Key { get; set; }
/// <summary>
/// 服务器对应Key
/// </summary>
[XmlAttribute("ServiceKey")]
public string ServiceKey { get; set; }
/// <summary>
/// 请求地址
/// </summary>
[XmlAttribute("Path")]
public string Path { get; set; }
/// <summary>
/// 头像下载地址
/// </summary>
[XmlAttribute("Remark")]
public string Remark { get; set; }
}
public class NodeConfig
{
public NodeConfig() { }
/// <summary>
/// 通讯服务器地址
/// </summary>
public NodeProp Xmpp { get; set; }
/// <summary>
/// 通讯服务器虚拟地址
/// </summary>
public NodeProp XmppDomain { get; set; }
/// <summary>
/// API接口地址
/// </summary>
public NodeProp Api { get; set; }
/// <summary>
/// 视频服务器地址
/// </summary>
public NodeProp Video { get; set; }
/// <summary>
/// 商城地址
/// </summary>
public NodeProp Mall { get; set; }
/// <summary>
/// 直播地址
/// </summary>
public NodeProp LiveBroadcast { get; set; }
/// <summary>
/// 文件上传地址
/// </summary>
public NodeProp FileUpload { get; set; }
/// <summary>
/// 文件下载地址
/// </summary>
public NodeProp FileDownload { get; set; }
/// <summary>
/// 头像下载地址
/// </summary>
public NodeProp FileDownloadHead { get; set; }
/// <summary>
/// 程序更新地址
/// </summary>
public NodeProp AppUpdate { get; set; }
/// <summary>
/// 配置文件地址
/// </summary>
public NodeProp AppConfig { get; set; }
}
/// <summary>
/// 节点项
/// </summary>
public class NodeItemConfig : NodeProp
{
public NodeItemConfig()
{
}
public NodeItemConfig(string path) : base(path)
{
}
public NodeItemConfig(string serviceKey, string path) : base(serviceKey, path)
{
}
public NodeItemConfig(string serviceKey, string path, string remark) : base(serviceKey, path, remark)
{
}
public NodeItemConfig(string key, string serviceKey, string path, string remark) : base(key, serviceKey, path, remark)
{
}
}
/// <summary>
/// 环境配置
/// </summary>
public class EnvConfig : NodeConfig
{
public EnvConfig()
{
}
public EnvConfig(string name)
{
Name = name;
}
public EnvConfig(string name, string remark)
{
Name = name;
Remark = remark;
}
/// <summary>
/// 名称
/// </summary>
[XmlAttribute("Name")]
public string Name { get; set; }
/// <summary>
/// 备注
/// </summary>
[XmlAttribute("Remark")]
public string Remark { get; set; }
}
/// <summary>
/// 环境节点
/// </summary>
[Serializable]
public class Envs : NodeConfig
{
public Envs() { }
/// <summary>
/// 环境配置节点
/// </summary>
public List<EnvConfig> Env { get; set; }
/// <summary>
/// 单个节点配置Node
/// </summary>
public List<NodeItemConfig> Nodes { get; set; }
}
XML帮助类
/// <summary>
/// XML 帮助类
/// </summary>
public class XmlHelper
{
private string XmlFilePath = string.Empty;
private XmlDocument xmlDoc = new XmlDocument();
public XmlHelper()
{
}
public XmlHelper(string xmlFilePath)
{
XmlFilePath = xmlFilePath;
try
{
if (!string.IsNullOrWhiteSpace(xmlFilePath) && !File.Exists(xmlFilePath))
{
File.Create(xmlFilePath);
}
xmlDoc.Load(XmlFilePath);
}
catch (Exception ex)
{
}
}
#region 加载XML
/// <summary>
/// 加载XML
/// </summary>
/// <returns>返回XML</returns>
public string LoadXml()
{
return xmlDoc.InnerXml;
}
/// <summary>
/// 加载XML 文件流
/// </summary>
/// <param name="encoding">文件编码</param>
/// <returns></returns>
public Stream LoadXmlStream(Encoding encoding)
{
byte[] array = encoding.GetBytes(xmlDoc.InnerXml);
MemoryStream stream;
using (stream = new MemoryStream(array))
{
stream.Dispose();
}
return stream;
}
#endregion
#region XML文档节点查询和读取
/// <summary>
/// 选择匹配XPath表达式的第一个节点XmlNode.
/// </summary>
/// <param name="xPath">要匹配的XPath表达式(例如:"//节点名//子节点名")</param>
/// <returns>返回XmlNode</returns>
public XmlNode GetXmlNodeByXpath(string xPath)
{
return xmlDoc.SelectSingleNode(xPath);
}
/// <summary>
/// 选择匹配XPath表达式的节点列表XmlNodeList.
/// </summary>
/// <param name="xPath">要匹配的XPath表达式(例如:"//节点名//子节点名")</param>
/// <returns>返回XmlNodeList</returns>
public XmlNodeList GetXmlNodesByXpath(string xPath)
{
return xmlDoc.SelectNodes(xPath);
}
/// <summary>
/// 选择匹配XPath表达式的第一个节点的匹配xmlAttributeName的属性XmlAttribute.
/// </summary>
/// <param name="xPath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
/// <param name="xmlAttributeName">要匹配xmlAttributeName的属性名称</param>
/// <returns>返回xmlAttributeName</returns>
public XmlAttribute GetXmlAttribute(string xPath, string xmlAttributeName)
{
string content = string.Empty;
XmlAttribute xmlAttribute = null;
XmlNode xmlNode = xmlDoc.SelectSingleNode(xPath);
if (xmlNode != null)
{
if (xmlNode.Attributes.Count > 0)
{
xmlAttribute = xmlNode.Attributes[xmlAttributeName];
}
}
return xmlAttribute;
}
#endregion
#region XML文档创建和节点或属性的添加、修改
/// <summary>
/// 创建一个XML文档
/// </summary>
/// <param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
/// <param name="rootNodeName">XML文档根节点名称(须指定一个根节点名称)</param>
/// <param name="version">XML文档版本号(必须为:"1.0")</param>
/// <param name="encoding">XML文档编码方式</param>
/// <param name="standalone">该值必须是"yes"或"no",如果为null,Save方法不在XML声明上写出独立属性</param>
/// <returns>成功返回true,失败返回false</returns>
public bool CreateXmlDocument(string rootNodeName, string version, string encoding, string standalone)
{
XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration(version, encoding, standalone);
XmlNode root = xmlDoc.CreateElement(rootNodeName);
xmlDoc.AppendChild(xmlDeclaration);
xmlDoc.AppendChild(root);
xmlDoc.Save(XmlFilePath);
return true;
}
/// <summary>
/// 依据匹配XPath表达式的第一个节点来创建它的子节点(如果此节点已存在则追加一个新的同名节点
/// </summary>
/// <param name="xPath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
/// <param name="xmlNodeName">要匹配xmlNodeName的节点名称</param>
/// <param name="innerText">节点文本值</param>
/// <param name="xmlAttributeName">要匹配xmlAttributeName的属性名称</param>
/// <param name="value">属性值</param>
/// <returns>成功返回true,失败返回false</returns>
public bool CreateXmlNodeByXPath(string xPath, string xmlNodeName, string innerText, string xmlAttributeName, string value)
{
XmlNode xmlNode = xmlDoc.SelectSingleNode(xPath);
if (xmlNode != null)
{
//存不存在此节点都创建
XmlElement subElement = xmlDoc.CreateElement(xmlNodeName);
subElement.InnerXml = innerText;
//如果属性和值参数都不为空则在此新节点上新增属性
if (!string.IsNullOrEmpty(xmlAttributeName) && !string.IsNullOrEmpty(value))
{
XmlAttribute xmlAttribute = xmlDoc.CreateAttribute(xmlAttributeName);
xmlAttribute.Value = value;
subElement.Attributes.Append(xmlAttribute);
}
xmlNode.AppendChild(subElement);
}
xmlDoc.Save(XmlFilePath); //保存到XML文档
return true;
}
/// <summary>
/// 依据匹配XPath表达式的第一个节点来创建或更新它的子节点(如果节点存在则更新,不存在则创建)
/// </summary>
/// <param name="xPath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
/// <param name="xmlNodeName">要匹配xmlNodeName的节点名称</param>
/// <param name="innerText">节点文本值</param>
/// <returns>成功返回true,失败返回false</returns>
public bool CreateOrUpdateXmlNodeByXPath(string xPath, string xmlNodeName, string innerText)
{
bool isExistsNode = false;//标识节点是否存在
XmlNode xmlNode = xmlDoc.SelectSingleNode(xPath);
if (xmlNode != null)
{
//遍历xPath节点下的所有子节点
foreach (XmlNode node in xmlNode.ChildNodes)
{
if (node.Name.ToLower() == xmlNodeName.ToLower())
{
//存在此节点则更新
node.InnerXml = innerText;
isExistsNode = true;
break;
}
}
if (!isExistsNode)
{
//不存在此节点则创建
XmlElement subElement = xmlDoc.CreateElement(xmlNodeName);
subElement.InnerXml = innerText;
xmlNode.AppendChild(subElement);
}
}
xmlDoc.Save(XmlFilePath); //保存到XML文档
return true;
}
/// <summary>
/// 依据匹配XPath表达式的第一个节点来创建或更新它的属性(如果属性存在则更新,不存在则创建)
/// </summary>
/// <param name="xPath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
/// <param name="xmlAttributeName">要匹配xmlAttributeName的属性名称</param>
/// <param name="value">属性值</param>
/// <returns>成功返回true,失败返回false</returns>
public bool CreateOrUpdateXmlAttributeByXPath(string xPath, string xmlAttributeName, string value)
{
bool isExistsAttribute = false;//标识属性是否存在
XmlNode xmlNode = xmlDoc.SelectSingleNode(xPath);
if (xmlNode != null)
{
//遍历xPath节点中的所有属性
foreach (XmlAttribute attribute in xmlNode.Attributes)
{
if (attribute.Name.ToLower() == xmlAttributeName.ToLower())
{
//节点中存在此属性则更新
attribute.Value = value;
isExistsAttribute = true;
break;
}
}
if (!isExistsAttribute)
{
//节点中不存在此属性则创建
XmlAttribute xmlAttribute = xmlDoc.CreateAttribute(xmlAttributeName);
xmlAttribute.Value = value;
xmlNode.Attributes.Append(xmlAttribute);
}
}
xmlDoc.Save(XmlFilePath); //保存到XML文档
return true;
}
#endregion
#region XML文档节点或属性的删除
/// <summary>
/// 删除匹配XPath表达式的第一个节点(节点中的子元素同时会被删除)
/// </summary>
/// <param name="xPath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
/// <returns>成功返回true,失败返回false</returns>
public bool DeleteXmlNodeByXPath(string xPath)
{
XmlNode xmlNode = xmlDoc.SelectSingleNode(xPath);
if (xmlNode != null)
{
//删除节点
xmlNode.ParentNode.RemoveChild(xmlNode);
}
xmlDoc.Save(XmlFilePath); //保存到XML文档
return true;
}
/// <summary>
/// 删除匹配XPath表达式的第一个节点中的匹配参数xmlAttributeName的属性
/// </summary>
/// <param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
/// <param name="xPath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
/// <param name="xmlAttributeName">要删除的xmlAttributeName的属性名称</param>
/// <returns>成功返回true,失败返回false</returns>
public bool DeleteXmlAttributeByXPath(string xPath, string xmlAttributeName)
{
bool isExistsAttribute = false;
XmlNode xmlNode = xmlDoc.SelectSingleNode(xPath);
XmlAttribute xmlAttribute = null;
if (xmlNode != null)
{
//遍历xPath节点中的所有属性
foreach (XmlAttribute attribute in xmlNode.Attributes)
{
if (attribute.Name.ToLower() == xmlAttributeName.ToLower())
{
//节点中存在此属性
xmlAttribute = attribute;
isExistsAttribute = true;
break;
}
}
if (isExistsAttribute)
{
//删除节点中的属性
xmlNode.Attributes.Remove(xmlAttribute);
}
}
xmlDoc.Save(XmlFilePath); //保存到XML文档
return true;
}
/// <summary>
/// 删除匹配XPath表达式的第一个节点中的所有属性
/// </summary>
/// <param name="xPath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
/// <returns>成功返回true,失败返回false</returns>
public bool DeleteAllXmlAttributeByXPath(string xPath)
{
XmlNode xmlNode = xmlDoc.SelectSingleNode(xPath);
if (xmlNode != null)
{
//遍历xPath节点中的所有属性
xmlNode.Attributes.RemoveAll();
}
xmlDoc.Save(XmlFilePath); //保存到XML文档
return true;
}
#endregion
#region 序列化/反序列化
#region 反序列化
/// <summary>
/// 反序列化
/// </summary>
/// <param name="type">类型</param>
/// <returns></returns>
public object XmlDeserialize(Type type)
{
using (StringReader sr = new StringReader(LoadXml()))
{
XmlSerializer xmldes = new XmlSerializer(type);
return xmldes.Deserialize(sr);
}
}
/// <summary>
/// 反序列化
/// </summary>
/// <param name="type">类型</param>
/// <param name="xml">XML字符串</param>
/// <returns></returns>
public object XmlDeserialize(Type type, string xml)
{
using (StringReader sr = new StringReader(xml))
{
XmlSerializer xmldes = new XmlSerializer(type);
return xmldes.Deserialize(sr);
}
}
/// <summary>
/// 反序列化
/// </summary>
/// <param name="type"></param>
/// <param name="stream">文件流</param>
/// <returns></returns>
public object XmlDeserialize(Type type, Stream stream)
{
XmlSerializer xmldes = new XmlSerializer(type);
return xmldes.Deserialize(stream);
}
/// <summary>
/// 反序列化
/// </summary>
/// <param name="type">转换类型</param>
/// <param name="encoding">编码</param>
/// <returns></returns>
public object XmlDeserialize(Type type, Encoding encoding)
{
XmlSerializer xmldes = new XmlSerializer(type);
return xmldes.Deserialize(LoadXmlStream(encoding));
}
#endregion
#region 序列化
/// <summary>
/// 序列化
/// </summary>
/// <param name="type">类型</param>
/// <param name="obj">对象</param>
/// <returns></returns>
public string XmlSerializer(Type type, object obj)
{
string str = string.Empty;
using (MemoryStream stream = new MemoryStream())
{
XmlSerializer xml = new XmlSerializer(type);
xml.Serialize(stream, obj);
stream.Position = 0;
using (StreamReader sr = new StreamReader(stream))
{
str = sr.ReadToEnd();
sr.Dispose();
}
stream.Dispose();
}
//序列化对象
return str;
}
#endregion
#endregion
}
调用示例
将实体类序列化成XML对象
var data = new Envs()
{
Xmpp = new NodeProp("XMPPHost", "https://xxx.com", "通讯服务器地址"),
XmppDomain = new NodeProp("XMPPDomain", "https://xxx.com", "通讯服务器虚拟地址"),
Api = new NodeProp("apiUrl", "https://xxx.com", "API接口地址"),
Video = new NodeProp("jitsiServer", "https://xxx.com", "视频服务器地址"),
Mall = new NodeProp("mallServerUrl", "", "商城地址"),
LiveBroadcast = new NodeProp("liveUrl", "rtmp://xxx/live/", "直播地址"),
FileUpload = new NodeProp("uploadUrl", "https://xxx.com", "文件上传地址"),
FileDownload = new NodeProp("downloadUrl", "https://xxx.com", "文件下载地址"),
FileDownloadHead = new NodeProp("downloadAvatarUrl", "http://xxx.com", "头像下载地址"),
AppUpdate = new NodeProp("", "http://xxx.com/packages/Huyouzhijia_win.msi", "程序更新地址"),
AppConfig = new NodeProp("", "http://xxx.com/packages/updata.xml", "配置文件地址"),
Env = new System.Collections.Generic.List<EnvConfig>()
{
new EnvConfig("Dev", "开发环境"){
Xmpp = new NodeProp("XMPPHost", "https://xxx.com", "通讯服务器地址"),
XmppDomain = new NodeProp("XMPPDomain", "https://xxx.com", "通讯服务器虚拟地址"),
Api = new NodeProp("apiUrl", "https://xxx.com", "API接口地址"),
Video = new NodeProp("jitsiServer", "https://xxx.com", "视频服务器地址"),
Mall = new NodeProp("mallServerUrl", "", "商城地址"),
LiveBroadcast = new NodeProp("liveUrl", "rtmp://xxx/live/", "直播地址"),
FileUpload = new NodeProp("uploadUrl", "https://xxx.com", "文件上传地址"),
FileDownload = new NodeProp("downloadUrl", "https://xxx.com", "文件下载地址"),
FileDownloadHead = new NodeProp("downloadAvatarUrl", "http://xxx.com", "头像下载地址"),
AppUpdate = new NodeProp("", "http://xxx.com/packages/Huyouzhijia_win.msi", "程序更新地址"),
AppConfig = new NodeProp("", "http://xxx.com/packages/updata.xml", "配置文件地址")
},
new EnvConfig("Uat", "堡垒环境"){
Xmpp = new NodeProp("XMPPHost", "https://xxx.com", "通讯服务器地址"),
XmppDomain = new NodeProp("XMPPDomain", "https://xxx.com", "通讯服务器虚拟地址"),
Api = new NodeProp("apiUrl", "https://xxx.com", "API接口地址"),
Video = new NodeProp("jitsiServer", "https://xxx.com", "视频服务器地址"),
Mall = new NodeProp("mallServerUrl", "", "商城地址"),
LiveBroadcast = new NodeProp("liveUrl", "rtmp://xxx/live/", "直播地址"),
FileUpload = new NodeProp("uploadUrl", "https://xxx.com", "文件上传地址"),
FileDownload = new NodeProp("downloadUrl", "https://xxx.com", "文件下载地址"),
FileDownloadHead = new NodeProp("downloadAvatarUrl", "http://xxx.com", "头像下载地址"),
AppUpdate = new NodeProp("", "http://xxx.com/packages/Huyouzhijia_win.msi", "程序更新地址"),
AppConfig = new NodeProp("", "http://xxx.com/packages/updata.xml", "配置文件地址")
},
new EnvConfig("Drp", "产出环境"){
Xmpp = new NodeProp("XMPPHost", "https://xxx.com", "通讯服务器地址"),
XmppDomain = new NodeProp("XMPPDomain", "https://xxx.com", "通讯服务器虚拟地址"),
Api = new NodeProp("apiUrl", "https://xxx.com", "API接口地址"),
Video = new NodeProp("jitsiServer", "https://xxx.com", "视频服务器地址"),
Mall = new NodeProp("mallServerUrl", "", "商城地址"),
LiveBroadcast = new NodeProp("liveUrl", "rtmp://xxx/live/", "直播地址"),
FileUpload = new NodeProp("uploadUrl", "https://xxx.com", "文件上传地址"),
FileDownload = new NodeProp("downloadUrl", "https://xxx.com", "文件下载地址"),
FileDownloadHead = new NodeProp("downloadAvatarUrl", "http://xxx.com", "头像下载地址"),
AppUpdate = new NodeProp("", "http://xxx.com/packages/Huyouzhijia_win.msi", "程序更新地址"),
AppConfig = new NodeProp("", "http://xxx.com/packages/updata.xml", "配置文件地址")
}
},
Nodes = new System.Collections.Generic.List<NodeItemConfig>()
{
new NodeItemConfig("Xmpp","XMPPHost", "https://xxx.com", "通讯服务器地址"),
new NodeItemConfig("XmppDomain","XMPPDomain", "https://xxx.com", "通讯服务器虚拟地址"),
new NodeItemConfig("Api","apiUrl", "https://xxx.com", "API接口地址"),
new NodeItemConfig("Video","jitsiServer", "https://xxx.com", "视频服务器地址"),
new NodeItemConfig("Mall","mallServerUrl", "", "商城地址"),
new NodeItemConfig("LiveBroadcast","liveUrl", "rtmp://xxx/live/", "直播地址"),
new NodeItemConfig("FileUpload","uploadUrl", "https://xxx.com", "文件上传地址"),
new NodeItemConfig("FileDownload","downloadUrl", "https://xxx.com", "文件下载地址"),
new NodeItemConfig("FileDownloadHead","downloadAvatarUrl", "http://xxx.com", "头像下载地址"),
new NodeItemConfig("AppUpdate","", "http://xxx.com/packages/Huyouzhijia_win.msi", "程序更新地址"),
new NodeItemConfig("AppConfig","", "http://xxx.com/packages/updata.xml", "配置文件地址")
}
};
var xml = new XmlHelper().XmlSerializer(typeof(Envs), data);