public static async Task <IFreeJiraSettings> UpdateSettings(FreeJiraSettings settings) { await SaveSettings(settings); _settings = null; return(await GetSettings()); }
private static string SerializeSettings(FreeJiraSettings settings) { return(JsonSerializer.Serialize( settings, new JsonSerializerOptions() { WriteIndented = true } )); }
/// <summary> /// Save settings to user folder /// </summary> /// <param name="settings"></param> /// <returns></returns> private static async Task <bool> SaveSettings(FreeJiraSettings settings) { var file = GetSettingsFile(); var json = SerializeSettings(settings); try { await File.WriteAllTextAsync(file.FullName, json); return(true); } catch { } return(false); }
/// <summary> /// set settings file with default values /// </summary> /// <returns></returns> private static async Task InitSettings(FileInfo file) { if (!file.Directory.Exists) { file.Directory.Create(); } if (!file.Exists) { var settings = new FreeJiraSettings() { BaseFolder = file.Directory.FullName }; await SaveSettings(settings); } }