-
Notifications
You must be signed in to change notification settings - Fork 0
/
TomlExample.cs
265 lines (201 loc) · 6.44 KB
/
TomlExample.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
namespace HKW.HKWTOML.Tests;
public class TomlExample
{
//public static string ExampleFile { get; set; } = "..\\..\\..\\Example.toml";
public static string ExampleData =>
@"
# This is an example HKWTOML document which shows most of its features.
# Simple key/value with a string.
title = ""HKWTOML example \U0001F60A""
desc = """"""
An example HKWTOML document. \
""""""
# Array with integers and floats in the various allowed formats.
integers = [42, 0x42, 0o42, 0b0110]
floats = [1.42, 1e-02]
# Array with supported datetime formats.
times = [
2021-11-09T15:16:17+01:00, # datetime with timezone.
2021-11-09T15:16:17Z, # UTC datetime.
2021-11-09T15:16:17, # local datetime.
2021-11-09, # local date.
15:16:17, # local time.
]
# Durations.
duration = [""4m49s"", ""8m03s"", ""1231h15m55s""]
# Table with inline tables.
distros = [
{name = ""Arch Linux"", packages = ""pacman""},
{name = ""Void Linux"", packages = ""xbps""},
{name = ""Debian"", packages = ""apt""},
]
# Create new table; note the ""servers"" table is created implicitly.
[servers.alpha]
# You can indent as you please, tabs or spaces.
ip = '10.0.0.1'
hostname = 'server1'
enabled = false
[servers.beta]
ip = '10.0.0.2'
hostname = 'server2'
enabled = true
# Start a new table array; note that the ""characters"" table is created implicitly.
[[characters.star-trek]]
name = ""James Kirk""
rank = ""Captain""
[[characters.star-trek]]
name = ""Spock""
rank = ""Science officer""
[undecoded] # To show the MetaData.Undecoded() feature.
key = ""This table intentionally left undecoded""
";
public static string ClassData =>
@"/// <summary>
/// This is an example HKWTOML document which shows most of its features.
/// </summary>
public class ExampleObject : ITomlObjectComment
{
/// <inheritdoc/>
public string ObjectComment { get; set; } = string.Empty;
/// <inheritdoc/>
public Dictionary<string, string> PropertyComments { get; set; } = new();
/// <summary>
/// Simple key/value with a string.
/// </summary>
[TomlPropertyOrder(0)]
[TomlPropertyName(""title"")]
public string Title { get; set; }
[TomlPropertyOrder(1)]
[TomlPropertyName(""desc"")]
public string Desc { get; set; }
/// <summary>
/// Array with integers and floats in the various allowed formats.
/// </summary>
[TomlPropertyOrder(2)]
[TomlPropertyName(""integers"")]
public List<int> Integers { get; set; }
[TomlPropertyOrder(3)]
[TomlPropertyName(""floats"")]
public List<double> Floats { get; set; }
/// <summary>
/// Array with supported datetime formats.
/// </summary>
[TomlPropertyOrder(4)]
[TomlPropertyName(""times"")]
public List<TomlNode> Times { get; set; }
/// <summary>
/// Durations.
/// </summary>
[TomlPropertyOrder(5)]
[TomlPropertyName(""duration"")]
public List<string> Duration { get; set; }
/// <summary>
/// Table with inline tables.
/// </summary>
[TomlPropertyOrder(6)]
[TomlPropertyName(""distros"")]
public List<DistrosAnonymousClass> Distros { get; set; }
[TomlPropertyOrder(7)]
[TomlPropertyName(""servers"")]
public ServersClass Servers { get; set; }
[TomlPropertyOrder(8)]
[TomlPropertyName(""characters"")]
public CharactersClass Characters { get; set; }
[TomlPropertyOrder(9)]
[TomlPropertyName(""undecoded"")]
public UndecodedClass Undecoded { get; set; }
}
public class DistrosAnonymousClass
{
[TomlPropertyOrder(0)]
[TomlPropertyName(""name"")]
public string Name { get; set; }
[TomlPropertyOrder(1)]
[TomlPropertyName(""packages"")]
public string Packages { get; set; }
}
public class ServersClass : ITomlObjectComment
{
/// <inheritdoc/>
public string ObjectComment { get; set; } = string.Empty;
/// <inheritdoc/>
public Dictionary<string, string> PropertyComments { get; set; } = new();
/// <summary>
/// Create new table; note the ""servers"" table is created implicitly.
/// </summary>
[TomlPropertyOrder(0)]
[TomlPropertyName(""alpha"")]
public AlphaClass Alpha { get; set; }
[TomlPropertyOrder(1)]
[TomlPropertyName(""beta"")]
public BetaClass Beta { get; set; }
}
/// <summary>
/// Create new table; note the ""servers"" table is created implicitly.
/// </summary>
public class AlphaClass : ITomlObjectComment
{
/// <inheritdoc/>
public string ObjectComment { get; set; } = string.Empty;
/// <inheritdoc/>
public Dictionary<string, string> PropertyComments { get; set; } = new();
/// <summary>
/// You can indent as you please, tabs or spaces.
/// </summary>
[TomlPropertyOrder(0)]
[TomlPropertyName(""ip"")]
public string Ip { get; set; }
[TomlPropertyOrder(1)]
[TomlPropertyName(""hostname"")]
public string Hostname { get; set; }
[TomlPropertyOrder(2)]
[TomlPropertyName(""enabled"")]
public bool Enabled { get; set; }
}
public class BetaClass : ITomlObjectComment
{
/// <inheritdoc/>
public string ObjectComment { get; set; } = string.Empty;
/// <inheritdoc/>
public Dictionary<string, string> PropertyComments { get; set; } = new();
[TomlPropertyOrder(0)]
[TomlPropertyName(""ip"")]
public string Ip { get; set; }
[TomlPropertyOrder(1)]
[TomlPropertyName(""hostname"")]
public string Hostname { get; set; }
[TomlPropertyOrder(2)]
[TomlPropertyName(""enabled"")]
public bool Enabled { get; set; }
}
public class CharactersClass : ITomlObjectComment
{
/// <inheritdoc/>
public string ObjectComment { get; set; } = string.Empty;
/// <inheritdoc/>
public Dictionary<string, string> PropertyComments { get; set; } = new();
[TomlPropertyOrder(0)]
[TomlPropertyName(""star-trek"")]
public List<Star-trekAnonymousClass> Star-trek { get; set; }
}
public class Star-trekAnonymousClass
{
[TomlPropertyOrder(0)]
[TomlPropertyName(""name"")]
public string Name { get; set; }
[TomlPropertyOrder(1)]
[TomlPropertyName(""rank"")]
public string Rank { get; set; }
}
public class UndecodedClass : ITomlObjectComment
{
/// <inheritdoc/>
public string ObjectComment { get; set; } = string.Empty;
/// <inheritdoc/>
public Dictionary<string, string> PropertyComments { get; set; } = new();
[TomlPropertyOrder(0)]
[TomlPropertyName(""key"")]
public string Key { get; set; }
}
";
}