Beispiel #1
0
        public static async Task SaveConfig(string configPath, GizmoConfig settings)
        {
            var configString = JsonConvert.SerializeObject(settings, Formatting.Indented);

            Directory.CreateDirectory(Path.GetDirectoryName(configPath));
            await File.WriteAllTextAsync(configPath, configString);
        }
Beispiel #2
0
        public static async Task <GizmoConfig> LoadConfig(string configPath)
        {
            GizmoConfig settings;

            if (File.Exists(configPath))
            {
                var configString = await File.ReadAllTextAsync(configPath);

                settings = JsonConvert.DeserializeObject <GizmoConfig>(configString);
            }
            else
            {
                settings = new GizmoConfig();
            }

            return(settings);
        }