Exemplo n.º 1
0
        public XmlDocument SaveProject()
        {
            if (ProjectName == "Project")
            {
                string fileName;
                if (ProjectManager.GetFileNameDialog(out fileName, _window))
                {
                    ProjectPath = fileName;
                    var sp = fileName.Split('\\');
                    ProjectName = sp.Length > 0 ? sp[sp.Length - 1].Split('.')[0] : "Invalid Project Name".Split('.')[0];
                }
            }

            var xml = new XmlDocument();

            xml.AppendChild(xml.CreateElement("Project"));
            if (xml.DocumentElement == null)
            {
                throw new ProjectLoadException();
            }
            xml.DocumentElement.AppendChild(xml.CreateElement("ProjectPath")).InnerText = ProjectPath;

            var rackSetupElement = xml.DocumentElement?.AppendChild(xml.CreateElement("RackSetups"));

            if (rackSetupElement == null)
            {
                return(xml);
            }
            foreach (var rackSetup in RackSetups)
            {
                rackSetup.Save(xml, rackSetupElement);
            }

            return(xml);
        }