buypeeb-cs/Settings.cs

54 lines
1.5 KiB
C#

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<string, Listing> 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<string, Listing>();
this.Watch("https://buypeeb.biz/whatever/k12345", "my thingy");
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<string, Listing> 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() {
// }
}
}