forked from wenjy/HighWayIot
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.9 KiB
C#
72 lines
1.9 KiB
C#
using HighWayIot.Repository.service;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml;
|
|
|
|
namespace HighWayIot.Winform.Business
|
|
{
|
|
/// <summary>
|
|
/// XML读写类
|
|
/// </summary>
|
|
public class XmlUtil
|
|
{
|
|
private static readonly Lazy<XmlUtil> lazy = new Lazy<XmlUtil>(() => new XmlUtil());
|
|
|
|
public static XmlUtil Instance
|
|
{
|
|
get
|
|
{
|
|
return lazy.Value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// XML读写实例
|
|
/// </summary>
|
|
XmlDocument xmlDocument = new XmlDocument();
|
|
|
|
/// <summary>
|
|
/// 运行时路径
|
|
/// </summary>
|
|
private string Path = System.Environment.CurrentDirectory;
|
|
|
|
public List<RoleConfig> ConfigReader()
|
|
{
|
|
List<RoleConfig> list = new List<RoleConfig>();
|
|
|
|
xmlDocument.Load($"{Path}\\Configuration.xml");
|
|
XmlNode root = xmlDocument.DocumentElement;
|
|
XmlNode node = root.SelectSingleNode("RoleConfig");
|
|
foreach (XmlNode role in node)
|
|
{
|
|
XmlAttribute pageName = (XmlAttribute)role.Attributes.GetNamedItem("PageName");
|
|
XmlAttribute roleIndex = (XmlAttribute)role.Attributes.GetNamedItem("RoleIndex");
|
|
int.TryParse(roleIndex.Value, out int index);
|
|
list.Add(new RoleConfig()
|
|
{
|
|
PageName = pageName.Value,
|
|
RoleIndex = index,
|
|
});
|
|
}
|
|
|
|
return list;
|
|
}
|
|
}
|
|
|
|
public class RoleConfig
|
|
{
|
|
/// <summary>
|
|
/// 页面名称
|
|
/// </summary>
|
|
public string PageName { get; set; }
|
|
|
|
/// <summary>
|
|
/// 规则编号
|
|
/// </summary>
|
|
public int RoleIndex { get; set; }
|
|
}
|
|
}
|