/// <summary>
        /// Populates this <see cref="Weight"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the weight data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a weight node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator weightNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("weight");

            Validator.ThrowInvalidIfNull(weightNav, Resources.WeightUnexpectedNode);

            _when = new HealthServiceDateTime();
            _when.ParseXml(weightNav.SelectSingleNode("when"));

            _value = new WeightValue();
            _value.ParseXml(weightNav.SelectSingleNode("value"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Populates this <see cref="WeightGoal"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the weight goal data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a weight-goal node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator weightGoalNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("weight-goal");

            Validator.ThrowInvalidIfNull(weightGoalNav, Resources.WeightGoalUnexpectedNode);

            XPathNavigator initialNav =
                weightGoalNav.SelectSingleNode("initial");

            if (initialNav != null)
            {
                _initialWeight = new WeightValue();
                _initialWeight.ParseXml(initialNav);
            }

            XPathNavigator minNav =
                weightGoalNav.SelectSingleNode("minimum");

            if (minNav != null)
            {
                _minWeight = new WeightValue();
                _minWeight.ParseXml(minNav);
            }

            XPathNavigator maxNav =
                weightGoalNav.SelectSingleNode("maximum");

            if (maxNav != null)
            {
                _maxWeight = new WeightValue();
                _maxWeight.ParseXml(maxNav);
            }

            XPathNavigator goalNav =
                weightGoalNav.SelectSingleNode("goal-info");

            if (goalNav != null)
            {
                _goal = new Goal();
                _goal.ParseXml(goalNav);
            }
        }
        /// <summary>
        /// Populates this <see cref="DietaryDailyIntake"/> instance from the
        /// data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the dietary intake data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a <see cref="DietaryDailyIntake"/> node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator intakeNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode(
                    "dietary-intake-daily");

            Validator.ThrowInvalidIfNull(intakeNav, Resources.DietaryDailyIntakeUnexpectedNode);

            _when = new HealthServiceDate();
            _when.ParseXml(intakeNav.SelectSingleNode("when"));

            XPathNavigator caloriesNav =
                intakeNav.SelectSingleNode("calories");

            if (caloriesNav != null)
            {
                _calories = caloriesNav.ValueAsInt;
            }

            XPathNavigator totalFatNav =
                intakeNav.SelectSingleNode("total-fat");

            if (totalFatNav != null)
            {
                _totalFat = new WeightValue();
                _totalFat.ParseXml(totalFatNav);
            }

            XPathNavigator satFatNav =
                intakeNav.SelectSingleNode("saturated-fat");

            if (satFatNav != null)
            {
                _saturatedFat = new WeightValue();
                _saturatedFat.ParseXml(satFatNav);
            }

            XPathNavigator transFatNav =
                intakeNav.SelectSingleNode("trans-fat");

            if (transFatNav != null)
            {
                _transFat = new WeightValue();
                _transFat.ParseXml(transFatNav);
            }

            XPathNavigator proteinNav =
                intakeNav.SelectSingleNode("protein");

            if (proteinNav != null)
            {
                _protein = new WeightValue();
                _protein.ParseXml(proteinNav);
            }

            XPathNavigator totalCarbsNav =
                intakeNav.SelectSingleNode("total-carbohydrates");

            if (totalCarbsNav != null)
            {
                _totalCarbs = new WeightValue();
                _totalCarbs.ParseXml(totalCarbsNav);
            }

            XPathNavigator fiberNav =
                intakeNav.SelectSingleNode("dietary-fiber");

            if (fiberNav != null)
            {
                _fiber = new WeightValue();
                _fiber.ParseXml(fiberNav);
            }

            XPathNavigator sugarsNav =
                intakeNav.SelectSingleNode("sugars");

            if (sugarsNav != null)
            {
                _sugars = new WeightValue();
                _sugars.ParseXml(sugarsNav);
            }

            XPathNavigator sodiumNav =
                intakeNav.SelectSingleNode("sodium");

            if (sodiumNav != null)
            {
                _sodium = new WeightValue();
                _sodium.ParseXml(sodiumNav);
            }

            XPathNavigator cholesterolNav =
                intakeNav.SelectSingleNode("cholesterol");

            if (cholesterolNav != null)
            {
                _cholesterol = new WeightValue();
                _cholesterol.ParseXml(cholesterolNav);
            }
        }