serialize enum as strings, strip more external data
This commit is contained in:
parent
64d16b8d81
commit
7e29e24bd4
25
Program.cs
25
Program.cs
@ -39,14 +39,11 @@ namespace creatureBirdDwarf
|
|||||||
string responseFromServer = dataStream.ReadToEnd();
|
string responseFromServer = dataStream.ReadToEnd();
|
||||||
OracleIDd = JsonConvert.DeserializeObject<List<Card>>(responseFromServer);
|
OracleIDd = JsonConvert.DeserializeObject<List<Card>>(responseFromServer);
|
||||||
}
|
}
|
||||||
foreach (var card in OracleIDd)
|
stripData(ref OracleIDd);
|
||||||
{
|
|
||||||
card.prices = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine("stripped price data, writing to file");
|
Console.WriteLine("stripped external (price and edhrec rank) data, writing to file");
|
||||||
|
|
||||||
File.WriteAllText("./oracle-now.json", JsonConvert.SerializeObject(OracleIDd, Formatting.Indented));
|
File.WriteAllText("./oracle-now.json", JsonConvert.SerializeObject(OracleIDd, Formatting.Indented, new Newtonsoft.Json.Converters.StringEnumConverter()));
|
||||||
var checksumNow = GetChecksum("./oracle-now.json");
|
var checksumNow = GetChecksum("./oracle-now.json");
|
||||||
Console.WriteLine($"oracled checksum: {checksumNow}");
|
Console.WriteLine($"oracled checksum: {checksumNow}");
|
||||||
|
|
||||||
@ -74,11 +71,8 @@ namespace creatureBirdDwarf
|
|||||||
{
|
{
|
||||||
string responseFromServer = dataStream.ReadToEnd();
|
string responseFromServer = dataStream.ReadToEnd();
|
||||||
defaultList = JsonConvert.DeserializeObject<List<Card>>(responseFromServer);
|
defaultList = JsonConvert.DeserializeObject<List<Card>>(responseFromServer);
|
||||||
foreach (var card in defaultList)
|
stripData(ref defaultList);
|
||||||
{
|
File.WriteAllText("./default.json", JsonConvert.SerializeObject(defaultList, Formatting.Indented, new Newtonsoft.Json.Converters.StringEnumConverter()));
|
||||||
card.prices = null;
|
|
||||||
}
|
|
||||||
File.WriteAllText("./default.json", JsonConvert.SerializeObject(defaultList, Formatting.Indented));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -88,6 +82,15 @@ namespace creatureBirdDwarf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void stripData(ref List<Card> collection)
|
||||||
|
{
|
||||||
|
foreach (var card in collection)
|
||||||
|
{
|
||||||
|
card.prices = null;
|
||||||
|
card.edhrec_rank = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static string GetChecksum(string filePath)
|
private static string GetChecksum(string filePath)
|
||||||
{
|
{
|
||||||
using (var stream = new BufferedStream(File.OpenRead(filePath), 1200000))
|
using (var stream = new BufferedStream(File.OpenRead(filePath), 1200000))
|
||||||
|
Loading…
Reference in New Issue
Block a user