public void Should_add_root_node()
 {
     XmlDocument xmlDoc = new XmlDocument();
     XmlNode rootNode = xmlDoc.AddRootNode("root");
     Check.That(xmlDoc.ChildNodes[1]).IsEqualTo(rootNode);
     Check.That(xmlDoc.ChildNodes[1].Name).IsEqualTo(rootNode.Name);
 }
Exemple #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="fileName"></param>
        public static bool SaveFile(string fileName)
        {
            const int version = 1;

            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlNode rootNode = xmlDoc.AddRootNode("FlowSimulator");
                rootNode.AddAttribute("version", version.ToString());

                FlowGraphManager.Instance.Save(rootNode);
                NamedVariableManager.Instance.Save(rootNode);

                xmlDoc.Save(fileName);

                LogManager.Instance.WriteLine(LogVerbosity.Info, "'{0}' successfully saved", fileName);
            }
            catch (System.Exception ex)
            {
                LogManager.Instance.WriteException(ex);
                return false;
            }

            return true;
        }
 public void Should_add_attribute_to_node()
 {
     XmlDocument xmlDoc = new XmlDocument();
     XmlNode rootNode = xmlDoc.AddRootNode("root");
     rootNode.AddAttribute("attribute", "value");
     Check.That(rootNode.Attributes["attribute"].Value).IsEqualTo("value");
 }
 public void Should_add_node_text()
 {
     XmlDocument xmlDoc = new XmlDocument();
     xmlDoc.AddRootNode("root");
     XmlElement nodeTxt = xmlDoc.CreateElementWithText("Text", "value");
     Check.That(nodeTxt.Name).IsEqualTo("Text");
     Check.That(nodeTxt.InnerText).IsEqualTo("value");
 }
        /// <summary>
        /// 
        /// </summary>
        private void SaveSettings()
        {
            var serializer = new XmlLayoutSerializer(dockingManager1);
            using (var stream = new StreamWriter(m_DockSettingsFile))
            {
                serializer.Serialize(stream);
            }

            XmlDocument xmlDoc = new XmlDocument();
            XmlNode rootNode = xmlDoc.AddRootNode("FlowSimulator");
            rootNode.AddAttribute("version", "1");
            XmlNode winNode = xmlDoc.CreateElement("Window");
            rootNode.AppendChild(winNode);
            winNode.AddAttribute("version", "1");

            if (WindowState == WindowState.Minimized)
            {
                winNode.AddAttribute("windowState", Enum.GetName(typeof(WindowState), WindowState.Normal));
                winNode.AddAttribute("left", m_LastLeft.ToString());
                winNode.AddAttribute("top", m_LastTop.ToString());
                winNode.AddAttribute("width", m_LastWidth.ToString());
                winNode.AddAttribute("height", m_LastHeight.ToString());
            }
            else
            {
                winNode.AddAttribute("windowState", Enum.GetName(typeof(WindowState), WindowState));
                winNode.AddAttribute("left", Left.ToString());
                winNode.AddAttribute("top", Top.ToString());
                winNode.AddAttribute("width", Width.ToString());
                winNode.AddAttribute("height", Height.ToString());
            }

            //             m_SessionControl.SaveSettings(rootNode);
            //             m_MessageControl.SaveSettings(rootNode);
            //             m_TaskControl.SaveSettings(rootNode);
            //             m_ReportControl.SaveSettings(rootNode);
            //             m_LogControl.SaveSettings(rootNode);
            //             m_ScriptControl.SaveSettings(rootNode);

            xmlDoc.Save(m_UserSettingsFile);
        }