예제 #1
0
        public static void WriteConfig(SoftSledConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            using (TextWriter textWriter = new StreamWriter(XML_Path, false)) {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(SoftSledConfig));
                xmlSerializer.Serialize(textWriter, config);
            }
        }
예제 #2
0
        public static SoftSledConfig ReadConfig()
        {
            SoftSledConfig config;

            if (!File.Exists(XML_Path))
            {
                // Config file does not exist, create a default one.

                config = new SoftSledConfig();
                WriteConfig(config);
            }

            using (TextReader textReader = new StreamReader(XML_Path)) {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(SoftSledConfig));
                config = (SoftSledConfig)xmlSerializer.Deserialize(textReader);
            }

            return(config);
        }