Beispiel #1
0
        /// <summary>
        /// Update the version of the specified file.
        /// </summary>
        /// <param name="fileName"></param>
        public static void UpdateFile(string fileName)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(fileName);
            string version = XmlUtilities.Value(doc.DocumentElement, "Version");

            if (version != new YieldProphet().Version.ToString())
            {
                YieldProphet ypSpec = YieldProphetOld.YieldProphetFromXML(doc.DocumentElement, Path.GetDirectoryName(fileName));
                string       xml    = XmlUtilities.Serialise(ypSpec, false, null);
                File.WriteAllText(fileName, xml);
            }
        }
Beispiel #2
0
        /// <summary>Factory method for creating a YieldProphet object.</summary>
        /// <param name="xml">The XML to use to create the object</param>
        /// <returns>The newly created object.</returns>
        public static YieldProphet YieldProphetFromXML(string xml, string workingFolder)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            if (XmlUtilities.Value(doc.DocumentElement, "Version") != "9")
            {
                return(YieldProphetOld.YieldProphetFromXML(doc.DocumentElement, workingFolder));
            }
            else
            {
                return(YieldProphetFromXML(doc.DocumentElement));
            }
        }