-
Notifications
You must be signed in to change notification settings - Fork 1
/
Info.cs
55 lines (41 loc) · 1.61 KB
/
Info.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using DragonFrontDb.Enums;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DragonFrontDb
{
public record Info
{
public Version DragonFontDbVersion { get; set; }
public Version DragonFrontVersion { get; set; }
public Version CardDataVersion { get; set; }
public Version CardDataCompatibleVersion { get; set;}
public string CardDataName { get; set; }
public string CardDataUrl { get; set; }
public string CardTraitsUrl { get; set; }
public DataStatus CardDataStatus { get; set; }
public Dictionary<Version, string> CardDataChangeLog { get; set; }
private static Info _info;
public static Info Current => _info ??
(_info = JsonConvert.DeserializeObject<Info>(Helper.GetResourceTextFile("Info.json"), new LegacyVersionConverter()));
}
public class LegacyVersionConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
serializer.Serialize(writer, value);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var dict = serializer.Deserialize<Dictionary<string, int>>(reader);
return new Version(dict["Major"], dict["Minor"], dict["Build"], 0); //revision not used
}
public override bool CanConvert(Type objectType)
{
return objectType == typeof(Version);
}
}
}