using Aitex.Core.Util; using MECF.Framework.Common.Equipment; 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 PowerSupplierItemManager : Singleton { #region 常量 /// /// 前缀 /// private const string PREFIX = "Power"; #endregion #region 内部变量 /// /// 字典 /// private Dictionary _moduleItemDictionary = new Dictionary(); #endregion #region 属性 /// /// 已经安装模块 /// public List InstalledModules { get; private set; } = new List(); #endregion /// /// 初始化 /// /// public void InitializeItem(XmlElement xmlElement) { PowerSupplierItem rpItem = new PowerSupplierItem(); rpItem.Installed = bool.Parse(xmlElement.SelectSingleNode("Installed").InnerText); rpItem.PowerSupplierID = int.Parse(xmlElement.SelectSingleNode("PowerSupplyID").InnerText); rpItem.SubType = xmlElement.SelectSingleNode("SubType").InnerText; rpItem.Count = int.Parse(xmlElement.SelectSingleNode("Count").InnerText); string key = $"{PREFIX}{rpItem.PowerSupplierID}"; if (rpItem.Installed && !InstalledModules.Contains(key)) { InstalledModules.Add(key); } _moduleItemDictionary[key] = rpItem; } /// /// 获取Power Supplier项 /// /// public PowerSupplierItem GetPowerSupplierItem(string moduleName) { return _moduleItemDictionary.ContainsKey(moduleName) ? _moduleItemDictionary[moduleName]:null; } } }