Пример #1
0
        /// <summary>
        /// Load a Trainer from file.
        /// </summary>
        /// <param name="name"></param>
        public void Load(string name)
        {
            // Create the path.
            var path = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "Data", name, string.Format("{0}.xml", name));
            var xml  = new ManagedXml.Reader(System.IO.File.ReadAllText(path)).Xml;

            // Set name values
            Username   = xml.GetAttributeValue("Username");
            Password   = xml.GetAttributeValue("Password");
            GameMaster = Convert.ToBoolean(xml.GetAttributeValue("GameMaster"));
        }
Пример #2
0
        /// <summary>
        /// Load a Trainer from file.
        /// </summary>
        /// <param name="name"></param>
        public void Load(string name)
        {
            // Create the path.
            var path     = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "Data", name, string.Format("{0}.xml", name));
            var xml      = new ManagedXml.Reader(System.IO.File.ReadAllText(path)).Xml;
            var nElement = xml.GetElement("Name");
            var n        = new Name();

            // Set root values
            Age    = Convert.ToInt32(xml.GetAttributeValue("Age"));
            Weight = Convert.ToDouble(xml.GetAttributeValue("Weight"));
            Height = Convert.ToDouble(xml.GetAttributeValue("Height"));
            Owner  = xml.GetAttributeValue("Owner");

            // Set name values
            n.First      = nElement.GetAttributeValue("First");
            n.Middle     = nElement.GetAttributeValue("Middle");
            n.Last       = nElement.GetAttributeValue("Last");
            n.Salutation = nElement.GetAttributeValue("Salutation");
            n.Suffix     = nElement.GetAttributeValue("Suffix");

            // Set name to root
            Name = n;
        }