don't serialise some unecessary stuff

This commit is contained in:
Lynne Megido 2020-09-06 13:10:00 +10:00
parent 4dd48e75b1
commit d9a4349a0a
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90
2 changed files with 13 additions and 2 deletions

View File

@ -573,6 +573,7 @@ namespace Buypeeb {
try {
using (var writer = new StreamWriter(sd.Filename))
using (var csv = new CsvWriter(writer, System.Globalization.CultureInfo.InvariantCulture)) {
csv.WriteRecords(this.settings.watchlist);
}
}

View File

@ -3,6 +3,8 @@ using System.Globalization;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using CsvHelper.Configuration.Attributes;
namespace Buypeeb {
class YahooAuctionsItem {
@ -23,6 +25,7 @@ namespace Buypeeb {
// the id *must* be saved!
// i'm also saving the original name to make it easier to tell what the items are in the userdata.json
// there's not really a need for it i guess but it's my program and i can do what i want
[Ignore]
public string id { get; set; }
public string name { get; set; }
private int price = 0;
@ -38,6 +41,7 @@ namespace Buypeeb {
public bool ready;
public bool available;
[Ignore, JsonIgnore]
public bool updatedRecently {
get {
var later = this.lastUpdated.AddSeconds(15);
@ -45,15 +49,21 @@ namespace Buypeeb {
}
}
// TODO: don't serialise this stuff
[JsonIgnore]
public string priceJPY { get { return $"¥{this.price}"; } }
[JsonIgnore]
public string winPriceJPY { get { return $"¥{this.winPrice}"; } }
[Ignore, JsonIgnore]
public string priceAUD { get { return $"${(this.price / 75.0):f2}"; } }
[Ignore, JsonIgnore]
public string winPriceAUD { get { return $"${(this.winPrice / 75.0):f2}"; } }
[Ignore, JsonIgnore]
public bool endingToday { get { return this.endDate.DayOfYear == DateTime.UtcNow.DayOfYear; } }
[Ignore, JsonIgnore]
public bool hasWinPrice { get { return this.winPrice != 0; } }
private bool success { get; set; } // TODO: custom setter that throws an exception if set to false or something idk
[Ignore, JsonIgnore]
public bool endingSoon { get { return DateTime.Compare(DateTime.UtcNow.AddMinutes(10), this.endDate) > 0; } }
private bool success { get; set; } // TODO: custom setter that throws an exception if set to false or something idk
public YahooAuctionsItem(string id, string name) {
this.id = id;