Beispiel #1
0
 private void InitData(string filePath)
 {
     _describes = new List <DescribeModel>();
     _devices   = new List <DeviceModel>();
     if (System.IO.File.Exists(filePath))
     {
         XmlDocument doc = new XmlDocument();
         doc.Load(filePath);
         XmlNodeList desNodes = doc.SelectSingleNode("BAS").SelectSingleNode("Describes").ChildNodes;
         XmlNodeList devNodes = doc.SelectSingleNode("BAS").SelectSingleNode("Devices").ChildNodes;
         foreach (XmlNode node in desNodes)
         {
             XmlElement    element = (XmlElement)node;
             DescribeModel model   = new DescribeModel()
             {
                 Code   = element.GetAttribute("Code"),
                 Value  = element.GetAttribute("Value"),
                 Remark = element.GetAttribute("Remark")
             };
             _describes.Add(model);
         }
         foreach (XmlNode node in devNodes)
         {
             XmlElement  element = (XmlElement)node;
             DeviceModel model   = new DeviceModel()
             {
                 Code  = element.GetAttribute("Code"),
                 Value = element.GetAttribute("Value"),
                 Floor = element.GetAttribute("Floor")
             };
             _devices.Add(model);
         }
     }
 }
Beispiel #2
0
        public DescribeModel GetDescribe(string tag)
        {
            DescribeModel model = new DescribeModel();
            var           query = _describes.Where(t => tag.Contains(t.Code));

            if (query.Any())
            {
                model = query.First();
            }
            return(model);
        }