using Aitex.Core.Util; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; namespace MECF.Framework.Common.ToolLayout { public class LoadPortItemManager : Singleton { #region 常量 /// /// 前缀 /// private const string PREFIX = "LP"; #endregion #region 内部变量 /// /// 字典 /// private Dictionary _loadPortItemDictionary=new Dictionary(); #endregion #region 属性 /// /// 已经安装模块 /// public List InstalledModules { get; private set; } = new List(); #endregion /// /// 初始化Load Port项 /// /// public void InitializeLoadPortItem(XmlElement xmlElement) { LoadPortItem loadPortItem = new LoadPortItem(); loadPortItem.Installed = bool.Parse(xmlElement.SelectSingleNode("Installed").InnerText); loadPortItem.Type = xmlElement.SelectSingleNode("Type").InnerText; loadPortItem.PortID = int.Parse(xmlElement.SelectSingleNode("PortID").InnerText); loadPortItem.SubType = xmlElement.SelectSingleNode("SubType").InnerText; string key = $"{PREFIX}{loadPortItem.PortID}"; if(loadPortItem.Installed && !InstalledModules.Contains(key)) { InstalledModules.Add(key); } _loadPortItemDictionary[key] = loadPortItem; } /// /// 获取Load Port Item对象 /// /// /// public LoadPortItem GetLoadPortItem(string moduleName) { return _loadPortItemDictionary.ContainsKey(moduleName) ? _loadPortItemDictionary[moduleName] : null; } } }