示例#1
0
        /// <summary>
        /// Loads settings from XML.
        /// </summary>
        static public bool LoadSettings()
        {
            string cacheFilePath = Path.Combine(Application.dataPath, "MachinationsSettings.xml");

            //Cannot work until Machinations Settings have been defined.
            if (!File.Exists(cacheFilePath))
            {
                return(false);
            }

            FileStream    fs = new FileStream(cacheFilePath, FileMode.Open);
            XmlSerializer xs = new XmlSerializer(typeof(MnConfig));

            try
            {
                MnConfig config = (MnConfig)xs.Deserialize(fs);
                fs.Close();
                Instance = config;
            }
            catch
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Saves settings to XML.
        /// </summary>
        static public void SaveSettings()
        {
            if (Instance == null)
            {
                Instance = new MnConfig();
            }
            string        cacheFilePath = Path.Combine(Application.dataPath, "MachinationsSettings.xml");
            FileStream    fs            = new FileStream(cacheFilePath, FileMode.Create);
            XmlSerializer xs            = new XmlSerializer(typeof(MnConfig));

            xs.Serialize(fs, Instance);
            fs.Close();
        }