Пример #1
0
        /// <summary>
        /// This will save the Trainer to file.
        /// </summary>
        public void Save()
        {
            // Create variables
            var path = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "Data", Owner, Name.First, string.Format("{0}.xml", Name.First));
            var xml  = new ManagedXml.Writer("Trainer");

            // Create attributes
            xml.Root.Attributes.Add(ManagedXml.Attribute.Create("Weight", Weight.ToString()));
            xml.Root.Attributes.Add(ManagedXml.Attribute.Create("Height", Height.ToString()));
            xml.Root.Attributes.Add(ManagedXml.Attribute.Create("Age", Age.ToString()));
            xml.Root.Attributes.Add(ManagedXml.Attribute.Create("Owner", Owner));

            // Create a name element
            var name = ManagedXml.Element.Create("Name");

            // Add the attributes.
            name.Attributes.Add(ManagedXml.Attribute.Create("First", Name.First));
            name.Attributes.Add(ManagedXml.Attribute.Create("Middle", Name.Middle));
            name.Attributes.Add(ManagedXml.Attribute.Create("Last", Name.Last));
            name.Attributes.Add(ManagedXml.Attribute.Create("Salutation", Name.Salutation));
            name.Attributes.Add(ManagedXml.Attribute.Create("Suffix", Name.Suffix));

            // Add back
            xml.AddElement(name);

            // Save
            System.IO.File.WriteAllText(path, xml.ToXML());
        }
Пример #2
0
        /// <summary>
        /// This will save the Trainer to file.
        /// </summary>
        public void Save()
        {
            // Create variables
            var path = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "Data", Username, string.Format("{0}.xml", Username));
            var xml  = new ManagedXml.Writer("User");

            // Create attributes
            xml.Root.Attributes.Add(ManagedXml.Attribute.Create("Username", Username));
            xml.Root.Attributes.Add(ManagedXml.Attribute.Create("Password", Password));
            xml.Root.Attributes.Add(ManagedXml.Attribute.Create("GameMaster", GameMaster.ToString()));

            // Save
            System.IO.File.WriteAllText(path, xml.ToXML());
        }