GetDefaultSettings() публичный статический Метод

public static GetDefaultSettings ( ) : Settings
Результат Settings
Пример #1
0
        /// <summary>
        /// Opens the settings file and loads the values
        /// </summary>
        public static void LoadSettings(Game game)
        {
            try
            {
                Settings settings;
                //If config does not exist, create it and write the default settings
                if (!File.Exists(configFile))
                {
                    SaveAndApplyDefault(game);
                    return;
                }
                string json = File.ReadAllText(configFile);
                //If config is empty, regenerate it
                if (string.IsNullOrWhiteSpace(json))
                {
                    SaveAndApplyDefault(game);
                    return;
                }
                settings = JsonConvert.DeserializeObject <Settings>(json);
                ApplySettings(settings, game);
            }
            catch (Exception ex)
            {
#if DEBUG
                throw ex;
#else
                System.Windows.Forms.MessageBox.Show(ex.Message + "\nTry deleting your config file!", game.Window.Title + " Configuration Error");
                //Default fallback settings
                ApplySettings(Settings.GetDefaultSettings(), game);
#endif
            }
        }
Пример #2
0
 private static void SaveAndApplyDefault(Game game)
 {
     SaveSettings(Settings.GetDefaultSettings());
     ApplySettings(Settings.GetDefaultSettings(), game);
 }