public Worker(IOptionsMonitor <AccountSettings> settingsMonitor, ILogger <Worker> logger, IServiceProvider services, IHostApplicationLifetime appLifetime) { this.settings = settingsMonitor.CurrentValue; settingsMonitor.OnChange(changedSettings => { this.settings = changedSettings; this.AccountsData = new AccountsData { Items = this.settings.Accounts.Where(a => a.Enabled).ToList() }; }); this.logger = logger; this.services = services; this.appLifetime = appLifetime; this.autoCompletionHandler = new AutoCompletionHandler(this); }
private static string GetSettingsFile() { if (!File.Exists(SettingsFile)) { var settings = new AccountSettings { Query = AzDoService.DefaultQuery, Slicers = "Tags,Priority,IterationPath", Accounts = new[] { new Account { Name = "Account-1", Org = "Org-1", Project = "Project-1", Token = "PAT Token for Org-1/Project-1", Enabled = true }, new Account { Name = "Account-2", Type = AccountType.Jira, Org = "Org-2", Project = "Project-2", Token = "[email protected]:apiToken", Query = JiraService.DefaultQuery, Enabled = true } } }; SetSettings(settings); ColorConsole.WriteLine("Update settings here: ".Red(), SettingsFile); } return(SettingsFile); }
public JiraService(IOptionsMonitor <AccountSettings> settingsMonitor) { this.settings = settingsMonitor.CurrentValue; settingsMonitor.OnChange(changedSettings => { this.settings = changedSettings; }); }
private static void SetSettings(AccountSettings settings) { File.WriteAllText(SettingsFile, JsonConvert.SerializeObject(settings, new JsonSerializerSettings { Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore })); }