Beispiel #1
0
        public void ReadXml(XmlReader reader)
        {
            reader.ReadStartElement();
            gold = long.Parse(reader.ReadInnerXml());
            xp   = long.Parse(reader.ReadInnerXml());

            // Read habits
            bool isEmpty = reader.IsEmptyElement;

            reader.ReadStartElement();
            if (!isEmpty)
            {
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    Habit habit = new Habit();
                    habit.ReadXml(reader);
                    habits.Add(habit);
                }
            }

            // Read dailies
            isEmpty = reader.IsEmptyElement;
            reader.ReadStartElement();
            if (!isEmpty)
            {
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    Daily daily = new Daily();
                    daily.ReadXml(reader);
                    dailies.Add(daily);
                }
            }

            // Read tasks
            isEmpty = reader.IsEmptyElement;
            reader.ReadStartElement();
            if (!isEmpty)
            {
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    Task task = new Task();
                    task.ReadXml(reader);
                    tasks.Add(task);
                }
            }

            // Read rewards
            isEmpty = reader.IsEmptyElement;
            reader.ReadStartElement();
            if (!isEmpty)
            {
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    Reward reward = new Reward();
                    reward.ReadXml(reader);
                    rewards.Add(reward);
                }
            }

            reader.ReadEndElement();
            reader.ReadEndElement();
        }