123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- 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<PufItemManager>
- {
- #region 常量
- /// <summary>
- /// 前缀
- /// </summary>
- private const string PREFIX = "PUF";
- #endregion
- #region 内部变量
- /// <summary>
- /// 字典
- /// </summary>
- private Dictionary<string,PufItem> _pufItemDictionary=new Dictionary<string, PufItem>();
- #endregion
- #region 属性
- /// <summary>
- /// 已经安装模块
- /// </summary>
- public List<string> InstalledModules { get; private set; } = new List<string>();
- #endregion
- /// <summary>
- /// 初始化Puf Item
- /// </summary>
- /// <param name="xmlElement"></param>
- 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;
- }
- /// <summary>
- /// 获取PufItem对象
- /// </summary>
- /// <param name="moduleName"></param>
- /// <returns></returns>
- public PufItem GetPufItem(string moduleName)
- {
- return _pufItemDictionary.ContainsKey(moduleName) ? _pufItemDictionary[moduleName] : null;
- }
- }
- }
|