/// <summary>
        /// Writes the dose to the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer element for the dose.
        /// </param>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the dose to.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// The <paramref name="nodeName"/> parameter is null or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="writer"/> parameter is null.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);

            writer.WriteStartElement(nodeName);

            XmlWriterHelper.WriteOptString(
                writer,
                "description",
                _description);

            XmlWriterHelper.WriteOptDouble(
                writer,
                "exact-dose",
                _exactDose);

            XmlWriterHelper.WriteOptDouble(
                writer,
                "min-dose",
                _minDose);

            XmlWriterHelper.WriteOptDouble(
                writer,
                "max-dose",
                _maxDose);

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the XML representation of the delivery into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the delivery.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the delivery should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// The <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);

            writer.WriteStartElement(nodeName);

            XmlWriterHelper.WriteOpt(writer, "location", _location);
            XmlWriterHelper.WriteOpt(writer, "time-of-delivery", _timeOfDelivery);
            XmlWriterHelper.WriteOptDouble(writer, "labor-duration", _laborDuration);

            foreach (CodableValue complication in _complications)
            {
                complication.WriteXml("complications", writer);
            }

            foreach (CodableValue anesthesia in _anesthesia)
            {
                anesthesia.WriteXml("anesthesia", writer);
            }

            XmlWriterHelper.WriteOpt(writer, "delivery-method", _deliveryMethod);
            XmlWriterHelper.WriteOpt(writer, "outcome", _outcome);
            XmlWriterHelper.WriteOpt(writer, "baby", _baby);
            XmlWriterHelper.WriteOptString(writer, "note", _note);

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the XML representation of the DietaryIntake into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the dietary intake item.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the DietaryIntake should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="FoodItem"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "WriteXmlEmptyNodeName");
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_foodItem, Resources.FoodItemNullValue);

            writer.WriteStartElement(nodeName);

            _foodItem.WriteXml("food-item", writer);
            XmlWriterHelper.WriteOpt(writer, "serving-size", _servingSize);
            XmlWriterHelper.WriteOptDouble(writer, "servings-consumed", _servingsConsumed);
            XmlWriterHelper.WriteOpt(writer, "meal", _meal);
            XmlWriterHelper.WriteOpt(writer, "when", _when);
            XmlWriterHelper.WriteOpt(writer, "energy", _energy);
            XmlWriterHelper.WriteOpt(writer, "energy-from-fat", _energyFromFat);
            XmlWriterHelper.WriteOpt(writer, "total-fat", _totalFat);
            XmlWriterHelper.WriteOpt(writer, "saturated-fat", _saturatedFat);
            XmlWriterHelper.WriteOpt(writer, "trans-fat", _transFat);
            XmlWriterHelper.WriteOpt(writer, "monounsaturated-fat", _monounsaturatedFat);
            XmlWriterHelper.WriteOpt(writer, "polyunsaturated-fat", _polyunsaturatedFat);
            XmlWriterHelper.WriteOpt(writer, "protein", _protein);
            XmlWriterHelper.WriteOpt(writer, "carbohydrates", _carbohydrates);
            XmlWriterHelper.WriteOpt(writer, "dietary-fiber", _dietaryFiber);
            XmlWriterHelper.WriteOpt(writer, "sugars", _sugars);
            XmlWriterHelper.WriteOpt(writer, "sodium", _sodium);
            XmlWriterHelper.WriteOpt(writer, "cholesterol", _cholesterol);
            XmlWriterHelper.WriteOpt(writer, "calcium", _calcium);
            XmlWriterHelper.WriteOpt(writer, "iron", _iron);
            XmlWriterHelper.WriteOpt(writer, "magnesium", _magnesium);
            XmlWriterHelper.WriteOpt(writer, "phosphorus", _phosphorus);
            XmlWriterHelper.WriteOpt(writer, "potassium", _potassium);
            XmlWriterHelper.WriteOpt(writer, "zinc", _zinc);
            XmlWriterHelper.WriteOpt(writer, "vitamin-A-RAE", _vitaminARAE);
            XmlWriterHelper.WriteOpt(writer, "vitamin-E", _vitaminE);
            XmlWriterHelper.WriteOpt(writer, "vitamin-D", _vitaminD);
            XmlWriterHelper.WriteOpt(writer, "vitamin-C", _vitaminC);
            XmlWriterHelper.WriteOpt(writer, "thiamin", _thiamin);
            XmlWriterHelper.WriteOpt(writer, "riboflavin", _riboflavin);
            XmlWriterHelper.WriteOpt(writer, "niacin", _niacin);
            XmlWriterHelper.WriteOpt(writer, "vitamin-B-6", _vitaminB6);
            XmlWriterHelper.WriteOpt(writer, "folate-DFE", _folateDFE);
            XmlWriterHelper.WriteOpt(writer, "vitamin-B-12", _vitaminB12);
            XmlWriterHelper.WriteOpt(writer, "vitamin-K", _vitaminK);

            if (_additionalNutritionFacts.Count != 0)
            {
                writer.WriteStartElement("additional-nutrition-facts");

                foreach (NutritionFact nutritionFact in _additionalNutritionFacts)
                {
                    nutritionFact.WriteXml("nutrition-fact", writer);
                }

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
示例#4
0
        /// <summary>
        /// Writes the XML representation of the UnitConversion into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the unit conversion.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the UnitConversion should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfArgumentNull(writer, nameof(writer), Resources.WriteXmlNullWriter);

            writer.WriteStartElement("unit-conversion");

            XmlWriterHelper.WriteOptDouble(writer, "multiplier", _multiplier);
            XmlWriterHelper.WriteOptDouble(writer, "offset", _offset);
            writer.WriteEndElement();
        }
示例#5
0
        /// <summary>
        /// Writes the XML representation of the CarePlanGoalRange into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the medical image study series.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the CarePlanGoalRange should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "WriteXmlEmptyNodeName");
            Validator.ThrowIfWriterNull(writer);

            writer.WriteStartElement("goal-range");
            {
                writer.WriteElementString("status-indicator", _statusIndicator.ToString(CultureInfo.InvariantCulture));
                XmlWriterHelper.WriteOptDouble(writer, "minimum-value", _minimumValue);
                XmlWriterHelper.WriteOptDouble(writer, "maximum-value", _maximumValue);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the XML representation of the vital sign result into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the vital sign result.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the vital sign result should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// The <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="Title"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_title, Resources.VitalSignResultTitleNotSet);
            Validator.ThrowSerializationIfNull(_title.Text, Resources.CodableValueNullText);

            writer.WriteStartElement(nodeName);

            // <title>
            _title.WriteXml("title", writer);

            // <value>
            XmlWriterHelper.WriteOptDouble(
                writer,
                "value",
                _value);

            // <unit>
            XmlWriterHelper.WriteOpt(
                writer,
                "unit",
                _unit);

            // <reference-minimum>
            XmlWriterHelper.WriteOptDouble(
                writer,
                "reference-minimum",
                _referenceMinimum);

            // <reference-maximum>
            XmlWriterHelper.WriteOptDouble(
                writer,
                "reference-maximum",
                _referenceMaximum);

            // <text-value>
            XmlWriterHelper.WriteOptString(
                writer,
                "text-value",
                _textValue);

            // <flag>
            XmlWriterHelper.WriteOpt(
                writer,
                "flag",
                _flag);

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the exercise data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the exercise data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="When"/> is <b>null</b>.
        /// If <see cref="Activity"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_when, Resources.WhenNullValue);
            Validator.ThrowSerializationIfNull(_activity, Resources.ExerciseActivityNotSet);

            // <exercise>
            writer.WriteStartElement("exercise");

            // <when>
            _when.WriteXml("when", writer);

            // <activity>
            _activity.WriteXml("activity", writer);

            // <title>
            XmlWriterHelper.WriteOptString(
                writer,
                "title",
                _title);

            // <distance>
            if (_distance != null)
            {
                XmlWriterHelper.WriteOpt(writer, "distance", _distance);
            }

            // <duration>
            if (_duration != null)
            {
                XmlWriterHelper.WriteOptDouble(writer, "duration", _duration);
            }

            // <detail>
            foreach (ExerciseDetail exerciseDetail in _details.Values)
            {
                exerciseDetail.WriteXml("detail", writer);
            }

            // <segment>
            foreach (ExerciseSegment exerciseSegment in _segments)
            {
                exerciseSegment.WriteXml("segment", writer);
            }

            // </exercise>
            writer.WriteEndElement();
        }
示例#8
0
        /// <summary>
        /// Writes the lap to the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer element for the lap.
        /// </param>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the lap data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ArgumentException">
        /// The <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// The Activity property is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_activity, Resources.ExerciseSegmentActivityNotSet);

            writer.WriteStartElement(nodeName);

            // <activity>
            XmlWriterHelper.WriteOpt(
                writer,
                "activity",
                _activity);

            // <title>
            XmlWriterHelper.WriteOptString(
                writer,
                "title",
                _title);

            // <distance>
            if (_distance != null)
            {
                _distance.WriteXml("distance", writer);
            }

            // <duration>
            if (_duration != null)
            {
                XmlWriterHelper.WriteOptDouble(writer, "duration", _duration);
            }

            // <offset>
            if (_offset != null)
            {
                XmlWriterHelper.WriteOptDouble(writer, "offset", _offset);
            }

            // <details>
            foreach (ExerciseDetail exerciseDetail in _details.Values)
            {
                exerciseDetail.WriteXml("detail", writer);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the lab result type data to the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer element for the lab result type.
        /// </param>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the lab result type to.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// The <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);

            writer.WriteStartElement(nodeName);

            XmlWriterHelper.WriteOptDouble(writer, "value", _value);
            XmlWriterHelper.WriteOpt(writer, "unit", _unit);
            XmlWriterHelper.WriteOpt(writer, "reference-range", _referenceRange);
            XmlWriterHelper.WriteOpt(writer, "toxic-range", _toxicRange);
            XmlWriterHelper.WriteOptString(writer, "text-value", _textValue);

            foreach (CodableValue flagValue in _flag)
            {
                flagValue.WriteXml("flag", writer);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the range data to the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer element for the range data.
        /// </param>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the range data to.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// The <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);

            writer.WriteStartElement(nodeName);

            // minimum
            XmlWriterHelper.WriteOptDouble(
                writer,
                "minimum-range",
                _minimum);

            // maximum
            XmlWriterHelper.WriteOptDouble(
                writer,
                "maximum-range",
                _maximum);

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the XML representation of the ClaimAmounts into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the ClaimAmounts.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the ClaimAmounts should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);

            writer.WriteStartElement(nodeName);

            XmlWriterHelper.WriteDecimal(writer, "charged-amount", _chargedAmount);
            XmlWriterHelper.WriteDecimal(writer, "negotiated-amount", _negotiatedAmount);
            XmlWriterHelper.WriteDecimal(writer, "copay", _coPayment);
            XmlWriterHelper.WriteDecimal(writer, "deductible", _deductible);
            XmlWriterHelper.WriteDecimal(writer, "amount-not-covered", _amountNotCovered);
            XmlWriterHelper.WriteDecimal(writer, "eligible-for-benefits", _eligibleForBenefits);

            XmlWriterHelper.WriteOptDouble(writer, "percentage-covered", _percentageCovered);

            XmlWriterHelper.WriteDecimal(writer, "coinsurance", _coinsurance);
            XmlWriterHelper.WriteDecimal(writer, "miscellaneous-adjustments", _miscellaneousAdjustments);
            XmlWriterHelper.WriteDecimal(writer, "benefits-paid", _benefitsPaid);
            XmlWriterHelper.WriteDecimal(writer, "patient-responsibility", _patientResponsibility);

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the body composition value data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the body composition value item.
        /// </param>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the body composition value data to.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="nodeName"/> is <b> null </b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b> null </b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);

            // <body-composition-value>
            writer.WriteStartElement(nodeName);

            // mass-value
            XmlWriterHelper.WriteOpt(
                writer,
                "mass-value",
                _massValue);

            // percent-value
            XmlWriterHelper.WriteOptDouble(
                writer,
                "percent-value",
                _percentValue);

            // </body-composition-value>
            writer.WriteEndElement();
        }
示例#13
0
        /// <summary>
        /// Writes the XML representation of the PAP session into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XML writer into which the PAP session should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="When"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_when, Resources.WhenNullValue);

            writer.WriteStartElement("pap-session");

            _when.WriteXml("when", writer);

            XmlWriterHelper.WriteOptDouble(writer, "duration-minutes", _durationMinutes);
            XmlWriterHelper.WriteOptDouble(writer, "apnea-hypopnea-index", _apneaHypopneaIndex);
            XmlWriterHelper.WriteOptDouble(writer, "apnea-index", _apneaIndex);
            XmlWriterHelper.WriteOptDouble(writer, "hypopnea-index", _hypopneaIndex);
            XmlWriterHelper.WriteOptDouble(writer, "oxygen-desaturation-index", _oxygenDesaturationIndex);

            XmlWriterHelper.WriteOpt(writer, "pressure", _pressure);
            XmlWriterHelper.WriteOpt(writer, "leak-rate", _leakRate);
            XmlWriterHelper.WriteOpt(writer, "tidal-volume", _tidalVolume);
            XmlWriterHelper.WriteOpt(writer, "minute-ventilation", _minuteVentilation);
            XmlWriterHelper.WriteOpt(writer, "respiratory-rate", _respiratoryRate);

            writer.WriteEndElement();
        }
示例#14
0
        /// <summary>
        /// Writes the aerobic profile data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the aerobic profile data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfArgumentNull(writer, nameof(writer), Resources.WriteXmlNullWriter);

            // <aerobic-profile>
            writer.WriteStartElement("aerobic-profile");

            // <when>
            _when.WriteXml("when", writer);

            // <max-heartrate>
            if (_maxHr != null)
            {
                writer.WriteElementString(
                    "max-heartrate",
                    _maxHr.Value.ToString(CultureInfo.InvariantCulture));
            }

            // <resting-heartrate>
            if (_restingHr != null)
            {
                writer.WriteElementString(
                    "resting-heartrate",
                    _restingHr.Value.ToString(CultureInfo.InvariantCulture));
            }

            // <anaerobic-threshold>
            if (_anaerobicThreshold != null)
            {
                writer.WriteElementString(
                    "anaerobic-threshold",
                    _anaerobicThreshold.Value.ToString(
                        CultureInfo.InvariantCulture));
            }

            if (_vo2Absolute != null || _vo2Relative != null)
            {
                writer.WriteStartElement("VO2-max");

                if (_vo2Absolute != null)
                {
                    XmlWriterHelper.WriteOptDouble(
                        writer,
                        "absolute",
                        _vo2Absolute.Value);
                }

                if (_vo2Relative != null)
                {
                    XmlWriterHelper.WriteOptDouble(
                        writer,
                        "relative",
                        _vo2Relative.Value);
                }

                writer.WriteEndElement();
            }

            foreach (HeartRateZoneGroup group in _zoneGroups)
            {
                group.WriteXml("heartrate-zone-group", writer);
            }

            // </aerobic-profile>
            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the aerobic data to the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer element for the aerobic data.
        /// </param>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the aerobic data to.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// The <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");

            Validator.ThrowIfArgumentNull(writer, nameof(writer), Resources.WriteXmlNullWriter);

            writer.WriteStartElement(nodeName);

            if (_mode.Text != null)
            {
                // <mode>
                _mode.WriteXml("mode", writer);
            }

            // <distance>
            _distance?.WriteXml("distance", writer);

            if (_minutes != null)
            {
                // <minutes>
                writer.WriteElementString(
                    "minutes",
                    XmlConvert.ToString(_minutes.Value));
            }

            if (_intensity != RelativeRating.None)
            {
                // <intensity>
                writer.WriteElementString(
                    "intensity",
                    ((int)_intensity).ToString(CultureInfo.InvariantCulture));
            }

            if (_peakHr != null)
            {
                // <peak-heartrate>
                writer.WriteElementString(
                    "peak-heartrate",
                    _peakHr.Value.ToString(CultureInfo.InvariantCulture));
            }

            if (_averageHr != null)
            {
                // <avg-heartrate>
                writer.WriteElementString(
                    "avg-heartrate",
                    _averageHr.Value.ToString(CultureInfo.InvariantCulture));
            }

            if (_minHr != null)
            {
                // <min-heartrate>
                writer.WriteElementString(
                    "min-heartrate",
                    _minHr.Value.ToString(CultureInfo.InvariantCulture));
            }

            XmlWriterHelper.WriteOptDouble(
                writer,
                "energy",
                _energy);

            XmlWriterHelper.WriteOptDouble(
                writer,
                "energy-from-fat",
                _energyFromFat);

            _peakSpeed?.WriteXml("peak-speed", writer);

            _averageSpeed?.WriteXml("avg-speed", writer);

            _minSpeed?.WriteXml("min-speed", writer);

            _peakPace?.WriteXml("peak-pace", writer);

            _averagePace?.WriteXml("avg-pace", writer);

            _minPace?.WriteXml("min-pace", writer);

            _peakPower?.WriteXml("peak-power", writer);

            _averagePower?.WriteXml("avg-power", writer);

            _minPower?.WriteXml("min-power", writer);

            _peakTorque?.WriteXml("peak-torque", writer);

            _averageTorque?.WriteXml("avg-torque", writer);

            _minTorque?.WriteXml("min-torque", writer);

            XmlWriterHelper.WriteOptDouble(
                writer,
                "left-right-balance",
                _leftRightBalance);

            XmlWriterHelper.WriteOptDouble(
                writer,
                "peak-cadence",
                _peakCadence);

            XmlWriterHelper.WriteOptDouble(
                writer,
                "avg-cadence",
                _averageCadence);

            XmlWriterHelper.WriteOptDouble(
                writer,
                "min-cadence",
                _minCadence);

            _peakTemperature?.WriteXml("peak-temperature", writer);

            _averageTemperature?.WriteXml("avg-temperature", writer);

            _minTemperature?.WriteXml("min-temperature", writer);

            _peakAltitude?.WriteXml("peak-altitude", writer);

            _averageAltitude?.WriteXml("avg-altitude", writer);

            _minAltitude?.WriteXml("min-altitude", writer);

            XmlWriterHelper.WriteOpt(writer, "elevation-gain", _elevationGain);
            XmlWriterHelper.WriteOpt(writer, "elevation-loss", _elevationLoss);
            XmlWriterHelper.WriteOptInt(writer, "number-of-steps", _numberOfSteps);
            XmlWriterHelper.WriteOptInt(writer, "number-of-aerobic-steps", _numberOfAerobicSteps);
            XmlWriterHelper.WriteOptDouble(writer, "aerobic-step-minutes", _aerobicStepMinutes);

            writer.WriteEndElement();
        }
示例#16
0
        /// <summary>
        /// Writes the insight data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the insight data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_raisedInsightId, Resources.InsightIdNullValue);
            Validator.ThrowSerializationIfNull(_catalogId, Resources.InsightCatalogIdNullValue);
            Validator.ThrowSerializationIfNull(_when, Resources.WhenNullValue);
            Validator.ThrowSerializationIfNull(_expirationDate, Resources.InsightExpirationDateNullValue);

            // <insight>
            writer.WriteStartElement("insight");

            // <raised-insight-id>
            writer.WriteElementString("raised-insight-id", _raisedInsightId);

            // <catalog-id>
            writer.WriteElementString("catalog-id", _catalogId);

            // <when>
            _when.WriteXml("when", writer);

            // <expiration-date>
            _expirationDate.WriteXml("expiration-date", writer);

            // <channel>
            XmlWriterHelper.WriteOptString(writer, "channel", _channel);

            // <algo-class>
            XmlWriterHelper.WriteOptString(writer, "algo-class", _algoClass);

            // <directionality>
            XmlWriterHelper.WriteOptString(writer, "directionality", _directionality);

            // <time-span-pivot>
            XmlWriterHelper.WriteOptString(writer, "time-span-pivot", _timespanPivot);

            // <comparison-pivot>
            XmlWriterHelper.WriteOptString(writer, "comparison-pivot", _comparisonPivot);

            // <tone-pivot>
            XmlWriterHelper.WriteOptString(writer, "tone-pivot", _tonePivot);

            // <scope-pivot>
            XmlWriterHelper.WriteOptString(writer, "scope-pivot", _scopePivot);

            // <data-used-pivot>
            WriteStringList(_dataUsedPivot, writer, "data-used-pivot", "data-used");

            // <annotation>
            XmlWriterHelper.WriteOptString(writer, "annotation", _annotation);

            // <strength>
            XmlWriterHelper.WriteOptDouble(writer, "strength", _strength);

            // <confidence>
            XmlWriterHelper.WriteOptDouble(writer, "confidence", _confidence);

            // <origin>
            XmlWriterHelper.WriteOptString(writer, "origin", _origin);

            // <tags>
            WriteStringList(_insightTags, writer, "tags", "tag");

            // <values>
            WriteDictionary(_values, writer, "values", "value");

            // <links>
            WriteDictionary(_links, writer, "links", "value");

            // </insight>
            writer.WriteEndElement();
        }