using System; using System.Collections.Generic; using System.IO; using System.Text.Json; namespace Buypeeb { class Settings { private string location; public int updateInterval { get; set; } = 10 * 60; public int favouriteUpdateInterval { get; set; } = 5 * 60; public int updateIntervalCritical { get; set; } = 60; public int favouriteUpdateIntervalCritical { get; set; } = 30; public Dictionary watchlist { get; set; } public Settings() { if (Environment.OSVersion.Platform == PlatformID.Win32NT) { // C:\Users\Beebus\AppData\Roaming\Lynnear Software\buypeeb this.location = Path.Combine(Environment.ExpandEnvironmentVariables("%APPDATA%"), "Lynnear Software", "buypeeb"); } else { // ~/.config/Lynnear Software/buypeeb this.location = Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".config", "Lynnear Software", "buypeeb"); } this.watchlist = new Dictionary(); this.Watch("https://buypeeb.biz/whatever/k12345", "my thingy"); this.Watch("https://buypeeb.biz/whatever/z09876", "your thingy"); this.Watch("https://buypeeb.biz/whatever/h55555", "our thingy"); for (int i = 0; i < 10; i++) { this.Watch($"https://buypeeb.biz/whatever/x{i * 123}", $"filler {i}"); } this.watchlist["k12345"].Update(); } public void Watch(string url, string name) { string id = BuypeebApp.IDFromURL(url); Console.WriteLine(id); this.watchlist[id] = new Listing(url, id, name); foreach (KeyValuePair entry in this.watchlist) { Console.WriteLine("{0} - {1}", entry.Value.name, entry.Value.price); } } public void Save() { string j = JsonSerializer.Serialize(this); Console.WriteLine(j); } // public void Load() { // } } }