1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 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 LoadPortItemManager : Singleton<LoadPortItemManager>
- {
- #region 常量
- /// <summary>
- /// 前缀
- /// </summary>
- private const string PREFIX = "LP";
- #endregion
- #region 内部变量
- /// <summary>
- /// 字典
- /// </summary>
- private Dictionary<string,LoadPortItem> _loadPortItemDictionary=new Dictionary<string, LoadPortItem>();
- #endregion
- #region 属性
- /// <summary>
- /// 已经安装模块
- /// </summary>
- public List<string> InstalledModules { get; private set; } = new List<string>();
- #endregion
- /// <summary>
- /// 初始化Load Port项
- /// </summary>
- /// <param name="xmlElement"></param>
- public void InitializeLoadPortItem(XmlElement xmlElement)
- {
- LoadPortItem loadPortItem = new LoadPortItem();
- loadPortItem.Installed = bool.Parse(xmlElement.SelectSingleNode("Installed").InnerText);
- loadPortItem.Type = xmlElement.SelectSingleNode("Type").InnerText;
- loadPortItem.PortID = int.Parse(xmlElement.SelectSingleNode("PortID").InnerText);
- loadPortItem.SubType = xmlElement.SelectSingleNode("SubType").InnerText;
- string key = $"{PREFIX}{loadPortItem.PortID}";
- if(loadPortItem.Installed && !InstalledModules.Contains(key))
- {
- InstalledModules.Add(key);
- }
- _loadPortItemDictionary[key] = loadPortItem;
- }
- /// <summary>
- /// 获取Load Port Item对象
- /// </summary>
- /// <param name="moduleName"></param>
- /// <returns></returns>
- public LoadPortItem GetLoadPortItem(string moduleName)
- {
- return _loadPortItemDictionary.ContainsKey(moduleName) ? _loadPortItemDictionary[moduleName] : null;
- }
- }
- }
|