public void SaveConfig(StrategyConfig config) { if (File.Exists(@"Config\Coins.config")) { File.Delete(@"Config\Coins.config"); } string json = ""; json = Newtonsoft.Json.JsonConvert.SerializeObject(config); using (StreamWriter sw = new StreamWriter(@"Config\Coins.config")) { sw.Write(json); } }
public static StrategyConfig LoadConfig() { if (File.Exists(@"Config\Coins.config")) { string json = ""; using (StreamReader sr = new StreamReader(@"Config\Coins.config")) { json = sr.ReadToEnd(); } StrategyConfig config = Newtonsoft.Json.JsonConvert.DeserializeObject <StrategyConfig>(json); return(config); } return(new StrategyConfig()); }