Beispiel #1
0
        public static void RunTest_Memory(string _filename, string _rootNode)
        {
            _xmlDoc = new PFXmlDocument(_rootNode);

            XmlElement xmlElement;
            XmlElement saveXmlElement;

            xmlElement     = _xmlDoc.AddNewElement(_xmlDoc.DocumentRootNode, "ProcessingDate", DateTime.Now.ToString());
            saveXmlElement = _xmlDoc.AddNewElement(_xmlDoc.DocumentRootNode, "IsEnabled", "True");
            xmlElement     = _xmlDoc.AddNewElement(saveXmlElement, "node1", "text1");
            xmlElement     = _xmlDoc.AddNewElement(saveXmlElement, "node2", "text2");
            _xmlDoc.AddNewAttribute(xmlElement, "attr1", "val1");
            xmlElement = _xmlDoc.AddNewElement(saveXmlElement, "node3", "text3");
            _xmlDoc.AddNewAttribute(xmlElement, "attr3a", "val3a");
            _xmlDoc.AddNewAttribute(xmlElement, "attr3b", "val3b");
            xmlElement = _xmlDoc.AddNewElement(_xmlDoc.DocumentRootNode, "FormBackground", "Red");
            _xmlDoc.SaveToFile(_filename);

            PFXmlDocument xmlDoc2 = new PFXmlDocument();

            xmlDoc2.LoadFromFile(_filename);
            Program._messageLog.WriteLine(xmlDoc2.OuterXml);
            Program._messageLog.WriteLine("\r\n" + xmlDoc2.InnerText);
            Program._messageLog.WriteLine("\r\n" + xmlDoc2.InnerXml);
        }
Beispiel #2
0
        /// <summary>
        /// Creates and initializes an instance of the class by loading a serialized version of the instance from a file.
        /// </summary>
        /// <param name="filePath">Full path for the input file.</param>
        /// <returns>An instance of PFDirectoryEx.</returns>
        public static PFDirectoryEx LoadFromXmlFile(string filePath)
        {
            //*************************************************************
            //Built-in serialization does not work on PFDirectoryEx class.
            //*************************************************************
            //XmlSerializer deserializer = new XmlSerializer(typeof(PFDirectoryEx));
            //TextReader textReader = new StreamReader(filePath);
            //PFDirectoryEx dirEx;
            //dirEx = (PFDirectoryEx)deserializer.Deserialize(textReader);
            //textReader.Close();
            //return dirEx;

            PFDirectoryEx pfD‏irectoryExInstance = null;

            PFXmlDocument xmldoc = new PFXmlDocument();

            xmldoc.LoadFromFile(filePath);
            string     searchPath         = xmldoc.DocumentRootNodeName + "/" + "FullName";
            XmlElement fullNameNode       = xmldoc.FindElement(searchPath);
            string     PathForNewInstance = string.Empty;

            if (fullNameNode != null)
            {
                PathForNewInstance = fullNameNode.InnerText;
            }
            if (PathForNewInstance.Length > 0)
            {
                pfD‏irectoryExInstance = new PFDirectoryEx(PathForNewInstance, true);
            }

            return(pfD‏irectoryExInstance);
        }
Beispiel #3
0
        public static void OpenXMLDoc(string _filename)
        {
            _xmlDoc.LoadFromFile(_filename);

            Program._messageLog.WriteLine("OuterXml:\r\n" + _xmlDoc.OuterXml + "\r\n");
            //Program._messageLog.WriteLine(_xmlDoc.InnerXml);
            //Program._messageLog.WriteLine(_xmlDoc.InnerText);
            Program._messageLog.WriteLine("ToString:\r\n" + _xmlDoc.ToString() + "\r\n");
        }