/// <summary> /// Populates the data for the date and time from the XML. /// </summary> /// /// <param name="navigator"> /// The XML node representing the date and time. /// </param> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); _date = new HealthServiceDate(); _date.ParseXml(navigator.SelectSingleNode("date")); XPathNavigator timeNav = navigator.SelectSingleNode("time"); if (timeNav != null) { _time = new ApproximateTime(); _time.ParseXml(timeNav); } else { _time = null; } XPathNavigator tzNav = navigator.SelectSingleNode("tz"); if (tzNav != null) { _timeZone = new CodableValue(); _timeZone.ParseXml(tzNav); } }
/// <summary> /// Populates the data from the specified XML. /// </summary> /// /// <param name="navigator"> /// The XML containing the occurrence information. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="navigator"/> parameter is <b>null</b>. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); _when = new ApproximateTime(); _when.ParseXml(navigator.SelectSingleNode("when")); _minutes = navigator.SelectSingleNode("minutes").ValueAsInt; }
/// <summary> /// Populates this <see cref="SleepJournalPM"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the evening sleep journal data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in <paramref name="typeSpecificXml"/> is not /// a sleep-pm node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator sleepNav = typeSpecificXml.CreateNavigator().SelectSingleNode("sleep-pm"); Validator.ThrowInvalidIfNull(sleepNav, Resources.SleepJournalPMUnexpectedNode); _when = new HealthServiceDateTime(); _when.ParseXml(sleepNav.SelectSingleNode("when")); XPathNodeIterator caffeineNodes = sleepNav.Select("caffeine"); foreach (XPathNavigator caffeineNav in caffeineNodes) { ApproximateTime caffeineTaken = new ApproximateTime(); caffeineTaken.ParseXml(caffeineNav); _caffeine.Add(caffeineTaken); } XPathNodeIterator alcoholNodes = sleepNav.Select("alcohol"); foreach (XPathNavigator alcoholNav in alcoholNodes) { ApproximateTime alcoholTaken = new ApproximateTime(); alcoholTaken.ParseXml(alcoholNav); _alcohol.Add(alcoholTaken); } XPathNodeIterator napNodes = sleepNav.Select("nap"); foreach (XPathNavigator napNav in napNodes) { Occurrence napTaken = new Occurrence(); napTaken.ParseXml(napNav); _naps.Add(napTaken); } XPathNodeIterator exerciseNodes = sleepNav.Select("exercise"); foreach (XPathNavigator exerciseNav in exerciseNodes) { Occurrence exerciseTaken = new Occurrence(); exerciseTaken.ParseXml(exerciseNav); _exercise.Add(exerciseTaken); } _sleepiness = (Sleepiness)sleepNav.SelectSingleNode("sleepiness").ValueAsInt; }
/// <summary> /// Populates this SleepJournalAM instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the morning sleep journal data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in the <paramref name="typeSpecificXml"/> parameter /// is not a sleep-am node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator sleepNav = typeSpecificXml.CreateNavigator().SelectSingleNode("sleep-am"); Validator.ThrowInvalidIfNull(sleepNav, Resources.SleepJournalAMUnexpectedNode); _when = new HealthServiceDateTime(); _when.ParseXml(sleepNav.SelectSingleNode("when")); _bedtime = new ApproximateTime(); _bedtime.ParseXml(sleepNav.SelectSingleNode("bed-time")); _wakeTime = new ApproximateTime(); _wakeTime.ParseXml(sleepNav.SelectSingleNode("wake-time")); _sleepMinutes = sleepNav.SelectSingleNode("sleep-minutes").ValueAsInt; _settlingMinutes = sleepNav.SelectSingleNode("settling-minutes").ValueAsInt; XPathNodeIterator awakeningsIterator = sleepNav.Select("awakening"); foreach (XPathNavigator awakeningNav in awakeningsIterator) { Occurrence awakening = new Occurrence(); awakening.ParseXml(awakeningNav); _awakenings.Add(awakening); } XPathNavigator medNav = sleepNav.SelectSingleNode("medications"); if (medNav != null) { _medications = new CodableValue(); _medications.ParseXml(medNav); } _wakeState = (WakeState)sleepNav.SelectSingleNode("wake-state").ValueAsInt; }
/// <summary> /// Populates the data from the specified XML. /// </summary> /// /// <param name="navigator"> /// The XML containing the address information. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="navigator"/> parameter is <b>null</b>. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); XPathNodeIterator dowIterator = navigator.Select("dow"); foreach (XPathNavigator dowNav in dowIterator) { _daysOfWeek.Add((DayOfWeek)(dowNav.ValueAsInt - 1)); } XPathNodeIterator timeIterator = navigator.Select("time"); foreach (XPathNavigator timeNav in timeIterator) { ApproximateTime time = new ApproximateTime(); time.ParseXml(timeNav); _times.Add(time); } }
/// <summary> /// Populates the data for the approximate date and time from the XML. /// </summary> /// /// <param name="navigator"> /// The XML node representing the approximate date and time. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="navigator"/> parameter is <b>null</b>. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); XPathNavigator structuredNav = navigator.SelectSingleNode("structured"); if (structuredNav != null) { _approximateDate = new ApproximateDate(); _approximateDate.ParseXml( structuredNav.SelectSingleNode("date")); XPathNavigator timeNav = structuredNav.SelectSingleNode("time"); if (timeNav != null) { _approximateTime = new ApproximateTime(); _approximateTime.ParseXml(timeNav); } else { _approximateTime = null; } XPathNavigator tzNav = structuredNav.SelectSingleNode("tz"); if (tzNav != null) { _timeZone = new CodableValue(); _timeZone.ParseXml(tzNav); } } else { _description = navigator.SelectSingleNode("descriptive").Value; _approximateDate = null; } }