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 BarcodeReaderItemManager : Singleton { #region 常量 /// /// 前缀 /// private const string PREFIX = "BR"; #endregion #region 内部变量 /// /// 字典 /// private Dictionary _moduleItemDictionary = new Dictionary(); #endregion #region 属性 /// /// 已经安装模块 /// public List InstalledModules { get; private set; } = new List(); #endregion /// /// 初始化 /// /// public void InitializeItem(XmlElement xmlElement) { BarcodeReaderItem rpItem = new BarcodeReaderItem(); rpItem.Installed = bool.Parse(xmlElement.SelectSingleNode("Installed").InnerText); rpItem.BarcodeReaderID = int.Parse(xmlElement.SelectSingleNode("BarcodeReaderID").InnerText); rpItem.Count = int.Parse(xmlElement.SelectSingleNode("Count").InnerText); string key = $"{PREFIX}{rpItem.BarcodeReaderID}"; if (rpItem.Installed && !InstalledModules.Contains(key)) { InstalledModules.Add(key); } _moduleItemDictionary[key] = rpItem; } /// /// 获取BarcodeReader项 /// /// public BarcodeReaderItem GetBarcodeReaderItem(string moduleName) { return _moduleItemDictionary.ContainsKey(moduleName) ? _moduleItemDictionary[moduleName] : null; } } }