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 PufItemManager : Singleton { #region 常量 /// /// 前缀 /// private const string PREFIX = "PUF"; #endregion #region 内部变量 /// /// 字典 /// private Dictionary _pufItemDictionary=new Dictionary(); #endregion #region 属性 /// /// 已经安装模块 /// public List InstalledModules { get; private set; } = new List(); #endregion /// /// 初始化Puf Item /// /// public void InitializePufItem(XmlElement xmlElement) { PufItem pufItem = new PufItem(); pufItem.Installed = bool.Parse(xmlElement.SelectSingleNode("Installed").InnerText); pufItem.PufID = int.Parse(xmlElement.SelectSingleNode("PufID").InnerText); string key = $"{PREFIX}{pufItem.PufID}"; if(pufItem.Installed&&!InstalledModules.Contains(key)) { InstalledModules.Add(key); } _pufItemDictionary[key] = pufItem; } /// /// 获取PufItem对象 /// /// /// public PufItem GetPufItem(string moduleName) { return _pufItemDictionary.ContainsKey(moduleName) ? _pufItemDictionary[moduleName] : null; } } }