コード例 #1
0
        public static async Task <IFreeJiraSettings> UpdateSettings(FreeJiraSettings settings)
        {
            await SaveSettings(settings);

            _settings = null;
            return(await GetSettings());
        }
コード例 #2
0
 private static string SerializeSettings(FreeJiraSettings settings)
 {
     return(JsonSerializer.Serialize(
                settings,
                new JsonSerializerOptions()
     {
         WriteIndented = true
     }
                ));
 }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        /// <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);
            }
        }