/// <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, "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);
            }
        }
예제 #2
0
        /// <summary>
        /// Populates this <see cref="LifeGoal"/> instance from the data in the XML.
        /// </summary>
        /// 
        /// <param name="typeSpecificXml">
        /// The XML to get the life goal data from.
        /// </param>
        /// 
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a life-goal node.
        /// </exception>
        /// 
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator lifeGoalNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("life-goal");

            Validator.ThrowInvalidIfNull(lifeGoalNav, "LifeGoalUnexpectedNode");

            _description = lifeGoalNav.SelectSingleNode("description").Value;

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

            if (goalNav != null)
            {
                _goal = new Goal();
                _goal.ParseXml(goalNav);
            }
        }