Beispiel #1
0
 /// <summary>
 /// Creates a new instance of the <see cref="SleepJournalAM"/> class
 /// specifying the mandatory values.
 /// </summary>
 ///
 /// <param name="when">
 /// The date and time when the AM sleep journal entry was taken.
 /// </param>
 ///
 /// <param name="bedtime">
 /// The approximate time the person went to bed.
 /// </param>
 ///
 /// <param name="wakeTime">
 /// The approximate time the person woke up.
 /// </param>
 ///
 /// <param name="sleepMinutes">
 /// The number of minutes the person slept.
 /// </param>
 ///
 /// <param name="settlingMinutes">
 /// The number of minutes it took the person to fall asleep after
 /// going to bed.
 /// </param>
 ///
 /// <param name="wakeState">
 /// The state of the person when they awoke.
 /// </param>
 ///
 /// <exception cref="ArgumentNullException">
 /// The <paramref name="when"/> parameter is <b>null</b>.
 /// </exception>
 ///
 /// <exception cref="ArgumentOutOfRangeException">
 /// The <paramref name="sleepMinutes"/> parameter or
 /// <paramref name="settlingMinutes"/> parameter is negative.
 /// </exception>
 ///
 public SleepJournalAM(
     HealthServiceDateTime when,
     ApproximateTime bedtime,
     ApproximateTime wakeTime,
     int sleepMinutes,
     int settlingMinutes,
     WakeState wakeState)
     : base(TypeId)
 {
     When            = when;
     Bedtime         = bedtime;
     WakeTime        = wakeTime;
     SleepMinutes    = sleepMinutes;
     SettlingMinutes = settlingMinutes;
     WakeState       = wakeState;
 }
        /// <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, "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>
 /// Creates a new instance of the <see cref="SleepJournalAM"/> class 
 /// specifying the mandatory values.
 /// </summary>
 /// 
 /// <param name="when">
 /// The date and time when the AM sleep journal entry was taken.
 /// </param>
 /// 
 /// <param name="bedtime">
 /// The approximate time the person went to bed.
 /// </param>
 /// 
 /// <param name="wakeTime">
 /// The approximate time the person woke up.
 /// </param>
 /// 
 /// <param name="sleepMinutes">
 /// The number of minutes the person slept.
 /// </param>
 /// 
 /// <param name="settlingMinutes">
 /// The number of minutes it took the person to fall asleep after
 /// going to bed.
 /// </param>
 /// 
 /// <param name="wakeState">
 /// The state of the person when they awoke.
 /// </param>
 /// 
 /// <exception cref="ArgumentNullException">
 /// The <paramref name="when"/> parameter is <b>null</b>.
 /// </exception>
 /// 
 /// <exception cref="ArgumentOutOfRangeException">
 /// The <paramref name="sleepMinutes"/> parameter or 
 /// <paramref name="settlingMinutes"/> parameter is negative.
 /// </exception>
 /// 
 public SleepJournalAM(
     HealthServiceDateTime when,
     ApproximateTime bedtime,
     ApproximateTime wakeTime,
     int sleepMinutes,
     int settlingMinutes,
     WakeState wakeState)
     : base(TypeId)
 {
     this.When = when;
     this.Bedtime = bedtime;
     this.WakeTime = wakeTime;
     this.SleepMinutes = sleepMinutes;
     this.SettlingMinutes = settlingMinutes;
     this.WakeState = wakeState;
 }