-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCardFileSettings.cs
117 lines (100 loc) · 2.49 KB
/
CardFileSettings.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel;
using System.Globalization;
namespace CardFilePBX
{
public class CardFileSettings : INotifyPropertyChanged
{
private LastFile _lastFile;
private Tariffs _tariffs;
private Date _date;
public static CardFileSettings FromJson(string json) => JsonConvert.DeserializeObject<CardFileSettings>(json, CardFilePBX.Converter.Settings);
[JsonProperty("lastFile")]
public LastFile LastFile
{
get => _lastFile;
set
{
_lastFile = value;
OnPropertyChanged(nameof(LastFile));
}
}
[JsonProperty("tariffs")]
public Tariffs Tariffs
{
get => _tariffs;
set
{
_tariffs = value;
OnPropertyChanged(nameof(Tariffs));
}
}
[JsonProperty("date")]
public Date Date
{
get => _date;
set
{
_date = value;
OnPropertyChanged(nameof(Date));
}
}
private CardFileSettings() { }
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
public partial class Date
{
[JsonProperty("currentPeriod")]
public string CurrentPeriod { get; set; }
}
public partial class LastFile
{
[JsonProperty("path")]
public string Path { get; set; }
}
public partial class Tariffs
{
[JsonProperty("mega")]
public Tariff Mega { get; set; }
[JsonProperty("maximum")]
public Tariff Maximum { get; set; }
[JsonProperty("vip")]
public Tariff Vip { get; set; }
[JsonProperty("premium")]
public Tariff Premium { get; set; }
[JsonProperty("bonus")]
public Tariff Bonus { get; set; }
}
public partial class Tariff
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("outgoing")]
public long Outgoing { get; set; }
[JsonProperty("incoming")]
public long Incoming { get; set; }
}
public static class Serialize
{
public static string ToJson(this CardFileSettings self) => JsonConvert.SerializeObject(self, CardFilePBX.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters =
{
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
Formatting = Formatting.Indented,
};
}
}