Beispiel #1
0
        public static void Save()
        {
            if (Instance == null)
                Instance = new Config();

            try {
                BinaryFormatter serializer = new BinaryFormatter();
                using (FileStream fs = File.Create(ConfigPath)) {
                    serializer.Serialize(fs, Instance);
                    fs.Flush();
                }
            }
            catch (Exception e) {
                Dicom.Debug.Log.Error(e.Message);
            }

            //try {
            //    XmlSerializer serializer = new XmlSerializer(typeof(Config));
            //    using (FileStream fs = File.Create(ConfigPath)) {
            //        serializer.Serialize(fs, Instance);
            //        fs.Flush();
            //    }
            //}
            //catch (Exception e) {
            //    Dicom.Debug.Log.Error(e.Message);
            //}
        }
Beispiel #2
0
        public static Config Load()
        {
            if (!File.Exists(ConfigPath)) {
                Instance = new Config();
                return Instance;
            }

            try {
                BinaryFormatter serializer = new BinaryFormatter();
                using (FileStream fs = new FileStream(ConfigPath, FileMode.Open)) {
                    Instance = (Config)serializer.Deserialize(fs);
                }
            }
            catch (Exception e) {
                Dicom.Debug.Log.Error(e.Message);
                Instance = new Config();
            }

            //try {
            //    XmlSerializer serializer = new XmlSerializer(typeof(Config));
            //    using (FileStream fs = new FileStream(ConfigPath, FileMode.Open)) {
            //        Instance = (Config)serializer.Deserialize(fs);
            //    }
            //}
            //catch (Exception e) {
            //    Dicom.Debug.Log.Error(e.Message);
            //    Instance = new Config();
            //}

            return Instance;
        }