Example #1
0
        public void Deserialize_V4(Stream stream, DataVersion version)
        {
            byte[] intBuffer = new byte[sizeof(Int32)];
            Int32 scheduledDatesCount;

            Deserialize_V0(stream, version);

            // Scheduled dates
            stream.Read(intBuffer, 0, sizeof(Int32));
            scheduledDatesCount = BitConverter.ToInt32(intBuffer, 0);
            ScheduledDates.Clear();
            for (int i = 0; i < scheduledDatesCount; ++i)
            {
                GarminFitnessDate newDate = new GarminFitnessDate();

                newDate.Deserialize(stream, version);
                ScheduleWorkout(newDate);
            }
        }
Example #2
0
        public override void Deserialize(XmlNode parentNode)
        {
            XmlNode STExtensionsNode = null;
            bool nameRead = false;

            m_Notes.Value = "";
            ScheduledDates.Clear();

            for (int i = 0; i < parentNode.ChildNodes.Count; ++i)
            {
                XmlNode child = parentNode.ChildNodes.Item(i);

                if (child.Name == "Name")
                {
                    m_Name.Deserialize(child);
                    nameRead = true;
                }
                else if (child.Name == "Notes")
                {
                    m_Notes.Deserialize(child);
                }
                else if (child.Name == "ScheduledOn")
                {
                    GarminFitnessDate newDate = new GarminFitnessDate();

                    newDate.Deserialize(child);
                    ScheduleWorkout(newDate);
                }
                else if (child.Name == Constants.ExtensionsTCXString)
                {
                    for (int j = 0; j < child.ChildNodes.Count; ++j)
                    {
                        XmlNode currentNode = child.ChildNodes[j];

                        // This condition remains for backsward compatibility with V0 exports
                        if (currentNode.Name == "SportTracksCategory" &&
                            currentNode.FirstChild.ChildNodes.Count == 1 &&
                            currentNode.FirstChild.FirstChild.GetType() == typeof(XmlText))
                        {
                            XmlText categoryNode = (XmlText)child.FirstChild.FirstChild;

                            Category = Utils.FindCategoryByIDSafe(categoryNode.Value);
                        }
                        else if (currentNode.Name == "SportTracksExtensions")
                        {
                            STExtensionsNode = currentNode;
                        }
                    }
                }
            }

            if (!nameRead)
            {
                throw new GarminFitnessXmlDeserializationException("Information missing in the XML node", parentNode);
            }

            m_Name.Value = GarminWorkoutManager.Instance.GetUniqueName(Name);

            Steps.Deserialize(parentNode);

            if (STExtensionsNode != null)
            {
                HandleSTExtension(STExtensionsNode);
            }
        }