Esempio n. 1
0
        public static void Initialize()
        {
            try
            {
                using (var strm = File.OpenRead(@".\Config\Bindings.xml"))
                {
                    var serializer = new XmlSerializer(typeof (KeyBindings));
                    Instance = (KeyBindings) serializer.Deserialize(strm);
                }

                Save();
            }
            catch(Exception)
            {
                Instance = new KeyBindings();
                try
                {
                    Directory.CreateDirectory(@".\Config");
                    using (var strm = File.Open(@".\Config\Bindings.xml", FileMode.Create, FileAccess.Write))
                    {
                        var serializer = new XmlSerializer(typeof (KeyBindings));
                        serializer.Serialize(strm, Instance);
                    }
                }
                catch(Exception e)
                {
                    Log.Warning("Unable to save Bindings.xml: " + e.Message);
                }
            }
        }