private void Setting_HoempageURL_ApplyButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { SettingProvider.Save(SettingKeys.HomepageURL, Setting_HomepageURL_TextBox.Text); homepageURL = SettingProvider.Load <string>(SettingKeys.HomepageURL); CheckHomepageURL(); }
public SettingPage() { InitializeComponent(); homepageURL = SettingProvider.Load <string>(SettingKeys.HomepageURL); InitControls(); }
public string Load() { _settingProvider.Load(); _writer.WriteLine("using config at " + _path); if (_settings.All(s => s.IsSet)) { return(null); } _settingProvider.Save(); var description = string.Join("\n", _settings.Where(s => !s.IsSet).Select(s => s.Description)); return(description + "\n need setting in config"); }
private string MakeSqLiteConnectionString() { //TODO move info to resources SQLiteConnectionStringBuilder sqLiteConnStrBuilder = new SQLiteConnectionStringBuilder(); string settingFile = "server_setting.json"; SettingProvider settingProvider = new SettingProvider(); NecSetting setting = settingProvider.Load <NecSetting>(settingFile); string sqLitePath = Path.Combine(setting.databaseSettings.sqLiteFolder, "db.sqlite"); sqLiteConnStrBuilder.DataSource = sqLitePath; sqLiteConnStrBuilder.Version = 3; sqLiteConnStrBuilder.Pooling = true; sqLiteConnStrBuilder.ForeignKeys = true; sqLiteConnStrBuilder.Flags = sqLiteConnStrBuilder.Flags & SQLiteConnectionFlags.StrictConformance; return(sqLiteConnStrBuilder.ConnectionString); }
public override CommandResultType Handle(ConsoleParameter parameter) { if (_server == null) { SettingProvider settingProvider = new SettingProvider(); NecSetting setting = settingProvider.Load <NecSetting>(SETTING_FILE); if (setting == null) { Logger.Info($"No `{SETTING_FILE}` file found, creating new"); setting = new NecSetting(); settingProvider.Save(setting, SETTING_FILE); } else { Logger.Info($"Loaded Setting from: {settingProvider.GetSettingsPath(SETTING_FILE)}"); } SettingProvider secretsProvider = new SettingProvider(setting.secretsFolder); NecSecret secret = secretsProvider.Load <NecSecret>(SECRET_FILE); if (secret == null) { Logger.Info($"No `{SECRET_FILE}` file found, creating new"); secret = new NecSecret(); secretsProvider.Save(secret, SECRET_FILE); } else { Logger.Info($"Loaded Secrets from: {secretsProvider.GetSettingsPath(SECRET_FILE)}"); } setting.discordBotToken = secret.discordBotToken; setting.databaseSettings.password = secret.databasePassword; LogProvider.Configure <NecLogger>(setting); _server = new NecServer(setting); } if (parameter.arguments.Contains("start")) { _server.Start(); if (_service) { while (_server.running) { Thread.Sleep(TimeSpan.FromMinutes(5)); } return(CommandResultType.Exit); } return(CommandResultType.Completed); } if (parameter.arguments.Contains("stop")) { _server.Stop(); return(CommandResultType.Completed); } return(CommandResultType.Continue); }