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 { try {
using (var writer = new StreamWriter(sd.Filename)) using (var writer = new StreamWriter(sd.Filename))
using (var csv = new CsvWriter(writer, System.Globalization.CultureInfo.InvariantCulture)) { using (var csv = new CsvWriter(writer, System.Globalization.CultureInfo.InvariantCulture)) {
csv.WriteRecords(this.settings.watchlist); csv.WriteRecords(this.settings.watchlist);
} }
} }

View file

@ -3,6 +3,8 @@ using System.Globalization;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization;
using CsvHelper.Configuration.Attributes;
namespace Buypeeb { namespace Buypeeb {
class YahooAuctionsItem { class YahooAuctionsItem {
@ -23,6 +25,7 @@ namespace Buypeeb {
// the id *must* be saved! // 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 // 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 // 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 id { get; set; }
public string name { get; set; } public string name { get; set; }
private int price = 0; private int price = 0;
@ -38,6 +41,7 @@ namespace Buypeeb {
public bool ready; public bool ready;
public bool available; public bool available;
[Ignore, JsonIgnore]
public bool updatedRecently { public bool updatedRecently {
get { get {
var later = this.lastUpdated.AddSeconds(15); 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}"; } } public string priceJPY { get { return $"¥{this.price}"; } }
[JsonIgnore]
public string winPriceJPY { get { return $"¥{this.winPrice}"; } } public string winPriceJPY { get { return $"¥{this.winPrice}"; } }
[Ignore, JsonIgnore]
public string priceAUD { get { return $"${(this.price / 75.0):f2}"; } } public string priceAUD { get { return $"${(this.price / 75.0):f2}"; } }
[Ignore, JsonIgnore]
public string winPriceAUD { get { return $"${(this.winPrice / 75.0):f2}"; } } public string winPriceAUD { get { return $"${(this.winPrice / 75.0):f2}"; } }
[Ignore, JsonIgnore]
public bool endingToday { get { return this.endDate.DayOfYear == DateTime.UtcNow.DayOfYear; } } public bool endingToday { get { return this.endDate.DayOfYear == DateTime.UtcNow.DayOfYear; } }
[Ignore, JsonIgnore]
public bool hasWinPrice { get { return this.winPrice != 0; } } 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; } } 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) { public YahooAuctionsItem(string id, string name) {
this.id = id; this.id = id;