/// <summary> /// Populates the data from the specified XML. /// </summary> /// /// <param name="navigator"> /// The XML containing the glucose zone information. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="navigator"/> parameter is null. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); string name = navigator.GetAttribute("name", string.Empty); if (name.Length != 0) { _name = name; } XPathNavigator lowNav = navigator.SelectSingleNode("lower-bound"); if (lowNav != null) { XPathNavigator absoluteNav = lowNav.SelectSingleNode("absolute-glucose"); if (absoluteNav != null) { _lowAbsolute = new BloodGlucoseMeasurement(); _lowAbsolute.ParseXml(absoluteNav); } else { XPathNavigator relativeNav = lowNav.SelectSingleNode("percent-max-glucose"); if (relativeNav != null) { _lowRelative = relativeNav.ValueAsDouble; } } } XPathNavigator upperNav = navigator.SelectSingleNode("upper-bound"); if (upperNav != null) { XPathNavigator absoluteNav = upperNav.SelectSingleNode("absolute-glucose"); if (absoluteNav != null) { _upperAbsolute = new BloodGlucoseMeasurement(); _upperAbsolute.ParseXml(absoluteNav); } else { XPathNavigator relativeNav = upperNav.SelectSingleNode("percent-max-glucose"); if (relativeNav != null) { _upperRelative = relativeNav.ValueAsDouble; } } } }
/// <summary> /// Populates this BloodGlucose instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the blood glucose data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in <paramref name="typeSpecificXml"/> is not /// a blood-glucose node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator bgNav = typeSpecificXml.CreateNavigator().SelectSingleNode( "blood-glucose"); Validator.ThrowInvalidIfNull(bgNav, Resources.BGUnexpectedNode); _when = new HealthServiceDateTime(); _when.ParseXml(bgNav.SelectSingleNode("when")); _value = new BloodGlucoseMeasurement(); _value.ParseXml(bgNav.SelectSingleNode("value")); _glucoseMeasurementType = new CodableValue(); _glucoseMeasurementType.ParseXml( bgNav.SelectSingleNode("glucose-measurement-type")); _outsideOperatingTemp = XPathHelper.GetOptNavValueAsBool( bgNav, "outside-operating-temp"); _isControlTest = XPathHelper.GetOptNavValueAsBool( bgNav, "is-control-test"); XPathNavigator normalcyNav = bgNav.SelectSingleNode("normalcy"); if (normalcyNav != null) { _normalcyValue = normalcyNav.ValueAsInt; if (_normalcyValue < (int)Normalcy.WellBelowNormal || _normalcyValue > (int)Normalcy.WellAboveNormal) { _normalcy = Normalcy.Unknown; } else { _normalcy = (Normalcy)_normalcyValue; } } _measurementContext = XPathHelper.GetOptNavValue <CodableValue>( bgNav, "measurement-context"); }