Example #1
0
        /// <summary>
        /// parse an xml node
        /// </summary>
        /// <param name="xnod"></param>
        /// <param name="level"></param>
        public override void LoadFromXml(XmlNode xnod, int level)
        {
            LoadNodeFromXml(xnod, level);

            if (xnod.Name == "Name")
                Name = xnod.InnerText;

            if (xnod.Name == "isMale")
                isMale = Convert.ToBoolean(xnod.InnerText);

            if (xnod.Name == "DateOfBirth")
                SetDateOfBirth(DateTime.Parse(xnod.InnerText));

            if (xnod.Name == "PhysicalAttributes")
            {
            }

            if (xnod.Name == "EyeColour")
                EyeColour = xnod.InnerText;

            if (xnod.Name == "HairColour")
                HairColour = xnod.InnerText;

            if (xnod.Name == "HairLength")
                HairLength = xnod.InnerText;

            if (xnod.Name == "FacialHair")
                FacialHair = xnod.InnerText;

            if (xnod.Name == "BodyBuild")
                BodyBuild = xnod.InnerText;

            if (xnod.Name == "Height")
                Height = xnod.InnerText;

            if (xnod.Name == "PersonalityAttributes")
            {
            }

            if (xnod.Name == "Extroversion")
                Extroversion = truthvalue.FromString(xnod.InnerText);

            if (xnod.Name == "Agreeableness")
                Agreeableness = truthvalue.FromString(xnod.InnerText);

            if (xnod.Name == "Conscientiousness")
                Conscientiousness = truthvalue.FromString(xnod.InnerText);

            if (xnod.Name == "Neuroticism")
                Neuroticism = truthvalue.FromString(xnod.InnerText);

            if (xnod.Name == "Openness")
                Openness = truthvalue.FromString(xnod.InnerText);

            if (xnod.Name == "Sexuality")
                Sexuality = xnod.InnerText;

            if (xnod.Name == "Beliefs")
            {
                beliefs.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    belief b = new belief();
                    b.LoadFromXml((XmlNode)(xnod.ChildNodes[i]), level);
                    beliefs.Add(b);
                }
            }

            if (xnod.Name == "Roles")
            {
                roles.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    role r = new role();
                    r.LoadFromXml((XmlNode)(xnod.ChildNodes[i]), level);
                    roles.Add(r);
                }
            }

            if (xnod.Name == "Possessions")
            {
                possessions.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    possession p = new possession();
                    p.LoadFromXml((XmlNode)(xnod.ChildNodes[i]), level);
                    possessions.Add(p);
                }
            }

            if (xnod.Name == "Relationships")
            {
                relationships.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    relationship r = new relationship();
                    r.LoadFromXml((XmlNode)(xnod.ChildNodes[i]), level);
                    relationships.Add(r);
                }
            }

            if (xnod.Name == "GeneralSkills")
            {
                generalskills.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    skill s = new skill();
                    s.LoadFromXml((XmlNode)(xnod.ChildNodes[i]), level);
                    generalskills.Add(s);
                }
            }

            if (xnod.Name == "Opinions")
            {
                opinions.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    opinion o = new opinion();
                    o.LoadFromXml((XmlNode)(xnod.ChildNodes[i]), level);
                    opinions.Add(o);
                }
            }

            // call recursively on all children of the current node
            if (xnod.HasChildNodes)
            {
                XmlNode xnodWorking = xnod.FirstChild;
                while (xnodWorking != null)
                {
                    LoadFromXml(xnodWorking, level + 1);
                    xnodWorking = xnodWorking.NextSibling;
                }
            }
        }
Example #2
0
        /// <summary>
        /// parse an xml node
        /// </summary>
        /// <param name="xnod"></param>
        /// <param name="level"></param>
        public void LoadFromXml(XmlNode xnod, int level)
        {
            if (xnod.Name == "Type")
                Type = xnod.InnerText;

            if (xnod.Name == "Date")
                SetStartTime(DateTime.Parse(xnod.InnerText));

            if (xnod.Name == "Description")
                Description = xnod.InnerText;

            if (xnod.Name == "Locations")
            {
                locations.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    location locn = new location();
                    locn.LoadFromXml((XmlNode)xnod.ChildNodes[i], level);
                    locations.Add(locn);
                }
            }

            if (xnod.Name == "People")
            {
                people.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    personality p = new personality();
                    p.LoadFromXml((XmlNode)xnod.ChildNodes[i], level);
                    people.Add(p);
                }
            }

            if (xnod.Name == "Possessions")
            {
                possessions.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    possession p = new possession();
                    p.LoadFromXml((XmlNode)xnod.ChildNodes[i], level);
                    possessions.Add(p);
                }
            }

            // call recursively on all children of the current node
            if (xnod.HasChildNodes)
            {
                XmlNode xnodWorking = xnod.FirstChild;
                while (xnodWorking != null)
                {
                    LoadFromXml(xnodWorking, level + 1);
                    xnodWorking = xnodWorking.NextSibling;
                }
            }
        }