public List <Device> GetDevices() { string path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); if (!File.Exists(path + "/Config.json")) { Console.WriteLine("Config file does not exist"); return(null); } string content = File.ReadAllText(path + "/Config.json"); DeviceObject tim = JsonConvert.DeserializeObject <DeviceObject>(content); return(tim.Devices); }
public bool SetDevices(List <Device> items) { Console.WriteLine("SetDevices"); if (!VerifyContent(items)) { return(false); } string path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); DeviceObject obj = new DeviceObject(); obj.Devices = items; string content = JsonConvert.SerializeObject(obj); File.WriteAllText(path + "/Config.json", content); return(true); }