12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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 LinmotItemManager : Singleton<LinmotItemManager>
- {
- #region 常量
- /// <summary>
- /// 前缀
- /// </summary>
- private const string PREFIX = "LNM";
- #endregion
- #region 内部变量
- /// <summary>
- /// 字典
- /// </summary>
- private Dictionary<string,LinmotItem> _linmotItemDictionary=new Dictionary<string, LinmotItem>();
- #endregion
- #region 属性
- /// <summary>
- /// 已经安装模块
- /// </summary>
- public List<string> InstalledModules { get; private set; } = new List<string>();
- #endregion
- /// <summary>
- /// 初始化Linmot Item
- /// </summary>
- /// <param name="xmlElement"></param>
- public void InitializeLinmotItem(XmlElement xmlElement)
- {
- LinmotItem linmotItem = new LinmotItem();
- linmotItem.Installed = bool.Parse(xmlElement.SelectSingleNode("Installed").InnerText);
- linmotItem.LinmotID = int.Parse(xmlElement.SelectSingleNode("LinmotID").InnerText);
- linmotItem.SubType = xmlElement.SelectSingleNode("SubType").InnerText;
- linmotItem.ResetSwitchOff = int.Parse(xmlElement.SelectSingleNode("ResetSwitchOff").InnerText);
- linmotItem.Count = int.Parse(xmlElement.SelectSingleNode("Count").InnerText);
- string key = $"{PREFIX}{linmotItem.LinmotID}";
- if(linmotItem.Installed&&!InstalledModules.Contains(key))
- {
- InstalledModules.Add(key);
- }
- _linmotItemDictionary[key] = linmotItem;
- }
- /// <summary>
- /// 获取LinmotItem对象
- /// </summary>
- /// <param name="moduleName"></param>
- /// <returns></returns>
- public LinmotItem GetLinmotItem(string moduleName)
- {
- return _linmotItemDictionary.ContainsKey(moduleName) ? _linmotItemDictionary[moduleName] : null;
- }
- }
- }
|