コード例 #1
0
 static Config()
 {
     try
     {
         Instance    = FromFile(FileName);
     } catch(FileNotFoundException)
     {
         Instance    = new Config();
     }
 }
コード例 #2
0
        private static void ToFile(string file, Config config)
        {
            var xs  = new XmlSerializer(typeof(Config));

            using(var s = File.OpenWrite(file))
            {
                xs.Serialize(s, config);
                s.SetLength(s.Position);
            }
        }