Exemplo n.º 1
0
        public bool SaveConfig(List <ProcessConfig> processConfigs)
        {
            var config = new CursorPrisonConfig
            {
                ProcessConfigs = processConfigs
            };

            try
            {
                File.WriteAllText(ConfigPath, JsonConvert.SerializeObject(config));
                return(true);
            } catch (Exception ex)
            {
                Log.Error(ex, "Failed to save config.");
                return(false);
            }
        }
Exemplo n.º 2
0
        public bool LoadConfig()
        {
            if (!File.Exists(ConfigPath))
            {
                Directory.CreateDirectory(Path.Combine(Environment.GetEnvironmentVariable("AppData"), "CursorPrison"));
                File.WriteAllText(ConfigPath, JsonConvert.SerializeObject(new CursorPrisonConfig()));
            }

            try
            {
                Config = JsonConvert.DeserializeObject <CursorPrisonConfig>(File.ReadAllText(ConfigPath));
                return(true);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Failed to load config.");
                return(false);
            }
        }