internal FanProfile(XmlNode node, GeneralOptions defaults) { Name = node.Attributes["name"].Value; this.Interval = Utils.ParseInt32(node.SelectSingleNode("interval")?.InnerText, defaults.interval); XmlNode hysteresis = node.SelectSingleNode("hysteresis"); UpHysteresis = Utils.ParseByte(hysteresis?.Attributes["up"]?.Value, defaults.UpHysteresis); DownHysteresis = Utils.ParseByte(hysteresis?.Attributes["down"]?.Value, defaults.DownHysteresis); bool.TryParse(node.Attributes["default"]?.Value, out IsDefault); XmlNodeList cfgPoints = node.SelectNodes("point"); this.Points = new TemperaturePoint[cfgPoints.Count]; for (var i = 0; i < this.Points.Length; i++) { node = cfgPoints[i]; ref TemperaturePoint pt = ref Points[i]; pt.Temperature = byte.Parse(node.Attributes["temp"].Value); pt.FanSpeed = byte.Parse(node.Attributes["fan"].Value); }
private void LoadFanConfigXML(string sxml) { XmlDocument doc = new XmlDocument(); doc.LoadXml(sxml); GeneralOptions general = new GeneralOptions(doc.SelectSingleNode("//configuration/general")); TVicPortOptions ports = new TVicPortOptions(doc.SelectSingleNode("//configuration/tvicports")); //List<FanProfile> profiles = new List<FanProfile>(); XmlNodeList xmlProfileDefs = doc.SelectNodes("//configuration/fanprofiles/profile"); FanProfile[] profiles = new FanProfile[xmlProfileDefs.Count]; for (int i = 0; i < profiles.Length; i++) { profiles[i] = (new FanProfile(xmlProfileDefs[i], general)); } //If we got this far, there was no exception. So it's safe to actually use the values. this._general = general; this._ports = ports; this._allProfiles = profiles; }