buypeeb-cs/Settings.cs

54 lines
1.5 KiB
C#
Raw Normal View History

2020-09-02 03:21:32 +00:00
using System;
2020-09-01 10:41:29 +00:00
using System.Collections.Generic;
2020-09-02 04:12:56 +00:00
using System.IO;
using System.Text.Json;
2020-09-01 10:41:29 +00:00
namespace Buypeeb {
2020-09-02 04:12:56 +00:00
2020-09-01 10:41:29 +00:00
class Settings {
2020-09-02 04:12:56 +00:00
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;
}
2020-09-01 10:41:29 +00:00
public Settings() {
2020-09-02 04:12:56 +00:00
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");
}
2020-09-01 10:41:29 +00:00
this.watchlist = new Dictionary<string, Listing>();
2020-09-02 03:21:32 +00:00
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);
}
2020-09-01 10:41:29 +00:00
}
2020-09-02 04:12:56 +00:00
public void Save() {
string j = JsonSerializer.Serialize(this);
Console.WriteLine(j);
}
// public void Load() {
// }
2020-09-01 10:41:29 +00:00
}
}