/// <summary> /// Creates a new instance of the <see cref="SleepJournalPM"/> class /// specifying the mandatory values. /// </summary> /// /// <param name="when"> /// The date/time when the PM sleep journal entry was taken. /// </param> /// /// <param name="sleepiness"> /// The state of sleepiness the person was in throughout the day. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="when"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ArgumentException"> /// The <paramref name="sleepiness"/> parameter is /// <see cref="ItemTypes.Sleepiness.Unknown"/>. /// </exception> /// public SleepJournalPM( HealthServiceDateTime when, Sleepiness sleepiness) : base(TypeId) { When = when; Sleepiness = sleepiness; }
/// <summary> /// Creates a new instance of the <see cref="SleepJournalPM"/> class /// specifying the mandatory values. /// </summary> /// /// <param name="when"> /// The date/time when the PM sleep journal entry was taken. /// </param> /// /// <param name="sleepiness"> /// The state of sleepiness the person was in throughout the day. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="when"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ArgumentException"> /// The <paramref name="sleepiness"/> parameter is /// <see cref="Microsoft.Health.ItemTypes.Sleepiness.Unknown"/>. /// </exception> /// public SleepJournalPM( HealthServiceDateTime when, Sleepiness sleepiness) : base(TypeId) { this.When = when; this.Sleepiness = sleepiness; }
/// <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, "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; }