12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- 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<VpwMainItemManager>
- {
- #region 常量
- /// <summary>
- /// 前缀
- /// </summary>
- private const string PREFIX = "VPWMain";
- #endregion
- #region 内部变量
- /// <summary>
- /// 字典
- /// </summary>
- private Dictionary<string,VpwMainItem> _vpwMainItemDictionary=new Dictionary<string, VpwMainItem>();
- #endregion
- #region 属性
- /// <summary>
- /// 已经安装模块
- /// </summary>
- public List<string> InstalledModules { get; private set; } = new List<string>();
- #endregion
- /// <summary>
- /// VpwMain
- /// </summary>
- /// <param name="rinservoirElement"></param>
- 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<VpwCellItem>();
- XmlNodeList itemsNode = mainElement.SelectNodes("Cells/Item");
- List<string> metals = new List<string>();
- 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;
- }
- /// <summary>
- /// 获取对象
- /// </summary>
- /// <param name="moduleName"></param>
- /// <returns></returns>
- public VpwMainItem GetItem(string moduleName)
- {
- return _vpwMainItemDictionary.ContainsKey(moduleName) ? _vpwMainItemDictionary[moduleName] : null;
- }
- }
- }
|