public void SerializeData(Stream stream)
        {
            switch (m_Type)
            {
                case DataType.Enum:
                case DataType.UInt8:
                case DataType.UInt8z:
                    {
                        for (int i = 0; i < ArraySize; ++i)
                        {
                            GarminFitnessByteRange data = new GarminFitnessByteRange(m_ByteValues[i]);

                            data.Serialize(stream);
                        }
                        break;
                    }
                case DataType.SInt8:
                    {
                        for (int i = 0; i < ArraySize; ++i)
                        {
                            GarminFitnessSByteRange data = new GarminFitnessSByteRange(m_SByteValues[i]);

                            data.Serialize(stream);
                        }
                        break;
                    }
                case DataType.UInt16:
                case DataType.UInt16z:
                    {
                        for (int i = 0; i < ArraySize; ++i)
                        {
                            GarminFitnessUInt16Range data = new GarminFitnessUInt16Range(m_UInt16Values[i]);

                            data.Serialize(stream);
                        }
                        break;
                    }
                case DataType.SInt16:
                    {
                        for (int i = 0; i < ArraySize; ++i)
                        {
                            GarminFitnessInt16Range data = new GarminFitnessInt16Range(m_Int16Values[i]);

                            data.Serialize(stream);
                        }
                        break;
                    }
                case DataType.UInt32:
                case DataType.UInt32z:
                    {
                        for (int i = 0; i < ArraySize; ++i)
                        {
                            GarminFitnessUInt32Range data = new GarminFitnessUInt32Range(m_UInt32Values[i]);

                            data.Serialize(stream);
                        }
                        break;
                    }
                case DataType.SInt32:
                    {
                        for (int i = 0; i < ArraySize; ++i)
                        {
                            GarminFitnessInt32Range data = new GarminFitnessInt32Range(m_Int32Values[i]);

                            data.Serialize(stream);
                        }
                        break;
                    }
                case DataType.Float32:
                    {
                        for (int i = 0; i < ArraySize; ++i)
                        {
                            GarminFitnessFloatRange data = new GarminFitnessFloatRange(m_SingleValues[i]);

                            data.Serialize(stream);
                        }
                        break;
                    }
                case DataType.Float64:
                    {
                        for (int i = 0; i < ArraySize; ++i)
                        {
                            GarminFitnessDoubleRange data = new GarminFitnessDoubleRange(m_DoubleValues[i]);

                            data.Serialize(stream);
                        }
                        break;
                    }
                case DataType.String:
                    {
                        Byte[] valueStored = new Byte[FieldSize];

                        for(int i = 0; i < valueStored.Length; ++i)
                        {
                            if (i < m_ByteValues.Length)
                            {
                                valueStored[i] = m_ByteValues[i];
                            }
                            else
                            {
                                valueStored[i] = 0;
                            }
                        }
                        stream.Write(valueStored, 0, valueStored.Length);
                        break;
                    }
                case DataType.Byte:
                    {
                        stream.Write(m_ByteValues, 0, m_ByteValues.Length);
                        break;
                    }
                default:
                    {
                        Debug.Assert(false);
                        break;
                    }
            }
        }
        public void Serialize(XmlNode parentNode, String nodeName, XmlDocument document)
        {
            XmlNode bikeNode, wheelInfoChild;

            bikeNode = document.CreateElement(nodeName);
            parentNode.AppendChild(bikeNode);

            m_HasCadenceSensor.SerializeAttribute(bikeNode, Constants.HasCadenceTCXString, document);

            m_HasPowerSensor.SerializeAttribute(bikeNode, Constants.HasPowerTCXString, document);

            m_Name.Serialize(bikeNode, "Name", document);

            m_OdometerInMeters.Serialize(bikeNode, Constants.OdometerTCXString, document);

            GarminFitnessDoubleRange weightInKg = new GarminFitnessDoubleRange(Weight.Convert(m_WeightInPounds, Weight.Units.Pound, Weight.Units.Kilogram));
            weightInKg.Serialize(bikeNode, Constants.WeightTCXString, document);

            // Wheel info node
            wheelInfoChild = document.CreateElement(Constants.WheelSizeTCXString);
            bikeNode.AppendChild(wheelInfoChild);

            m_AutoWheelSize.SerializeAttribute(wheelInfoChild, Constants.AutoWheelSizeTCXString, document);

            m_WheelSize.Serialize(wheelInfoChild, Constants.SizeMillimetersTCXString, document);
        }
        public override void Serialize(XmlNode parentNode, String nodeName, XmlDocument document)
        {
            base.Serialize(parentNode, nodeName, document);

            // This node was added by our parent...
            parentNode = parentNode.LastChild;

            XmlAttribute attribute;

            // Type
            attribute = document.CreateAttribute(Constants.XsiTypeTCXString, Constants.xsins);
            attribute.Value = Constants.SpeedRangeZoneTCXString[1];
            parentNode.Attributes.Append(attribute);

            // View as
            GarminFitnessBool viewAs = new GarminFitnessBool(ViewAsPace, Constants.SpeedOrPaceTCXString[0], Constants.SpeedOrPaceTCXString[1]);
            viewAs.Serialize(parentNode, Constants.ViewAsTCXString, document);

            // Low
            GarminFitnessDoubleRange lowInMetersPerSecond = new GarminFitnessDoubleRange(Utils.Clamp(Zone.Low, Constants.MinSpeedMetersPerSecond, Constants.MaxSpeedMetersPerSecond));
            lowInMetersPerSecond.Serialize(parentNode, Constants.LowInMeterPerSecTCXString, document);

            // High
            GarminFitnessDoubleRange highInMetersPerSecond = new GarminFitnessDoubleRange(Utils.Clamp(Zone.High, Constants.MinSpeedMetersPerSecond, Constants.MaxSpeedMetersPerSecond));
            highInMetersPerSecond.Serialize(parentNode, Constants.HighInMeterPerSecTCXString, document);

            // Extension
            Utils.SerializeSTZoneInfoXML(BaseTarget.ParentStep,
                                         BaseTarget.ParentStep.ParentConcreteWorkout.Category.SpeedZone,
                                         Zone, document);
        }
        public virtual void Serialize(XmlNode parentNode, String nodeName, XmlDocument document)
        {
            XmlAttribute attributeNode;
            XmlNode activityNode, currentChild;

            activityNode = document.CreateElement(nodeName);
            parentNode.AppendChild(activityNode);

            attributeNode = document.CreateAttribute("Sport");
            attributeNode.Value = Constants.GarminCategoryTCXString[(int)Category];
            activityNode.Attributes.Append(attributeNode);

            attributeNode = document.CreateAttribute(Constants.XsiTypeTCXString, Constants.xsins);
            attributeNode.Value = "ProfileActivity_t";
            activityNode.Attributes.Append(attributeNode);

            // Maximum heart rate
            currentChild = document.CreateElement(Constants.MaxHRBPMTCXString);
            activityNode.AppendChild(currentChild);
            m_MaxHeartRate.Serialize(currentChild, Constants.ValueTCXString, document);

            // Resting HR
            currentChild = document.CreateElement(Constants.RestHRBPMTCXString);
            activityNode.AppendChild(currentChild);
            GarminProfileManager.Instance.UserProfile.InternalRestingHeartRate.Serialize(currentChild, Constants.ValueTCXString, document);

            GarminFitnessDoubleRange gearWeightinKg = new GarminFitnessDoubleRange(Weight.Convert(m_GearWeightInPounds, Weight.Units.Pound, Weight.Units.Kilogram));

            gearWeightinKg.Serialize(activityNode, Constants.GearWeightTCXString, document);

            // HR zones
            for (int i = 0; i < Constants.GarminHRZoneCount; ++i)
            {
                currentChild = document.CreateElement(Constants.HeartRateZonesTCXString);
                activityNode.AppendChild(currentChild);

                // Number
                XmlNode numberNode = document.CreateElement("Number");
                numberNode.AppendChild(document.CreateTextNode((i + 1).ToString()));
                currentChild.AppendChild(numberNode);

                // View as BPM or % max
                GarminFitnessBool HRIsInPercentMax = new GarminFitnessBool(HRZonesReferential != HRReferential.HRReferential_BPM,
                                                                           Constants.PercentMaxTCXString,
                                                                           Constants.BPMTCXString);
                HRIsInPercentMax.Serialize(currentChild, Constants.ViewAsTCXString, document);

                // Low
                GarminFitnessByteRange lowLimit = new GarminFitnessByteRange((Byte)(m_HeartRateZones[i].Lower * MaximumHeartRate));
                XmlNode low = document.CreateElement(Constants.LowTCXString);
                currentChild.AppendChild(low);
                lowLimit.Serialize(low, Constants.ValueTCXString, document);

                // High
                GarminFitnessByteRange highLimit = new GarminFitnessByteRange((Byte)(m_HeartRateZones[i].Upper * MaximumHeartRate));
                XmlNode high = document.CreateElement(Constants.HighTCXString);
                currentChild.AppendChild(high);
                highLimit.Serialize(high, Constants.ValueTCXString, document);
            }

            // Speed zones
            for (int i = 0; i < Constants.GarminSpeedZoneCount; ++i)
            {
                currentChild = document.CreateElement(Constants.SpeedZonesTCXString);
                activityNode.AppendChild(currentChild);

                // Number
                XmlNode numberNode = document.CreateElement("Number");
                numberNode.AppendChild(document.CreateTextNode((i + 1).ToString()));
                currentChild.AppendChild(numberNode);

                // Name
                m_SpeedZones[i].InternalName.Serialize(currentChild, "Name", document);

                XmlNode valueChild = document.CreateElement(Constants.ValueTCXString);
                currentChild.AppendChild(valueChild);

                // View as pace or speed
                m_SpeedIsInPace.Serialize(valueChild, Constants.ViewAsTCXString, document);

                // Low
                m_SpeedZones[i].InternalLow.Serialize(valueChild, Constants.LowInMeterPerSecTCXString, document);

                // High
                m_SpeedZones[i].InternalHigh.Serialize(valueChild, Constants.HighInMeterPerSecTCXString, document);
            }
        }
        public override void Serialize(XmlNode parentNode, String nodeName, XmlDocument document)
        {
            base.Serialize(parentNode, nodeName, document);

            CultureInfo culture = new CultureInfo("en-us");

            // Low
            GarminFitnessDoubleRange low = new GarminFitnessDoubleRange(Zone.Low);
            low.Serialize(parentNode, "Low", document);

            // High
            GarminFitnessDoubleRange high = new GarminFitnessDoubleRange((Byte)Math.Min(Constants.MaxCadence, Zone.High));
            high.Serialize(parentNode, "High", document);

            // Extension
            Utils.SerializeSTZoneInfoXML(BaseTarget.ParentStep,
                                         Options.Instance.CadenceZoneCategory,
                                         Zone, document);
        }