コード例 #1
0
        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();
        }
コード例 #2
0
    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");
    }
コード例 #3
0
        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);
        }