using Aitex.Core.RT.DataCenter; 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 VpwMainItemManager : Singleton { #region 常量 /// /// 前缀 /// private const string PREFIX = "VPWMain"; #endregion #region 内部变量 /// /// 字典 /// private Dictionary _vpwMainItemDictionary=new Dictionary(); #endregion #region 属性 /// /// 已经安装模块 /// public List InstalledModules { get; private set; } = new List(); #endregion /// /// VpwMain /// /// public void InitializeVpwMainItem(XmlElement mainElement) { VpwMainItem vpwMainItem = new VpwMainItem(); vpwMainItem.Installed = bool.Parse(mainElement.SelectSingleNode("Installed").InnerText); vpwMainItem.VpwMainID = int.Parse(mainElement.SelectSingleNode("VpwMainID").InnerText); vpwMainItem.SubType = mainElement.SelectSingleNode("SubType").InnerText; string key = $"{PREFIX}{vpwMainItem.VpwMainID}"; vpwMainItem.VpwCells = new List(); XmlNodeList itemsNode = mainElement.SelectNodes("Cells/Item"); List metals = new List(); foreach (var item in itemsNode) { XmlElement element = item as XmlElement; VpwCellItem metalItem = VpwCellItemManager.Instance.InitializeVpwCellItem(element); VpwCellItemManager.Instance.AddCellItem(metalItem); vpwMainItem.VpwCells.Add(metalItem); } if (vpwMainItem.Installed && !InstalledModules.Contains(key)) { InstalledModules.Add(key); } _vpwMainItemDictionary[key] = vpwMainItem; } /// /// 获取对象 /// /// /// public VpwMainItem GetItem(string moduleName) { return _vpwMainItemDictionary.ContainsKey(moduleName) ? _vpwMainItemDictionary[moduleName] : null; } } }