Exemplo n.º 1
0
        /// <summary>
        /// Loads the configuration from the XML node.
        /// </summary>
        public void LoadFromXml(XmlElement xmlElem)
        {
            if (xmlElem == null)
            {
                throw new ArgumentNullException(nameof(xmlElem));
            }

            Active      = xmlElem.GetAttrAsBool("active");
            IsBound     = xmlElem.GetAttrAsBool("isBound");
            CommLineNum = xmlElem.GetAttrAsInt("number");
            Name        = xmlElem.GetAttrAsString("name");

            if (xmlElem.SelectSingleNode("LineOptions") is XmlNode lineOptionsNode)
            {
                LineOptions.LoadFromXml(lineOptionsNode);
            }

            if (xmlElem.SelectSingleNode("Channel") is XmlElement channelElem)
            {
                Channel.LoadFromXml(channelElem);
            }

            if (xmlElem.SelectSingleNode("CustomOptions") is XmlNode customOptionsNode)
            {
                CustomOptions.LoadFromXml(customOptionsNode);
            }

            if (xmlElem.SelectSingleNode("DevicePolling") is XmlNode devicePollingNode)
            {
                foreach (XmlElement deviceElem in devicePollingNode.SelectNodes("Device"))
                {
                    DeviceConfig deviceConfig = new DeviceConfig {
                        Parent = this
                    };
                    deviceConfig.LoadFromXml(deviceElem);
                    DevicePolling.Add(deviceConfig);
                }
            }
        }