-
Notifications
You must be signed in to change notification settings - Fork 0
/
Info.cs
120 lines (115 loc) · 5.66 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
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
using System.Xml;
public class Kazakhstan
{
public void fetch()
{
XmlDocument doc = new();
doc.Load("Info.xml");
XmlElement? xRoot = doc.DocumentElement;
if (xRoot != null)
{
foreach (XmlElement xnode in xRoot)
{
switch (xnode.Name)
{
case "API":
API = xnode.InnerText;
break;
case "WelcomeMessage":
WelcomeMessage = xnode.InnerText;
break;
case "HelpMessage":
HelpMessage = xnode.InnerText;
break;
case "GeneralInfo":
GeneralInfo = xnode.InnerText;
break;
case "History":
History = xnode.InnerText;
break;
case "Geography":
Geography = xnode.InnerText;
break;
case "Culture":
Culture = xnode.InnerText;
break;
case "Economy":
Economy = xnode.InnerText;
break;
case "Regions":
Regions = new List<KazakhstanRegion>();
foreach (XmlElement Xmlregion in xnode)
{
XmlNode? attr = Xmlregion.Attributes?.GetNamedItem("name");
if (attr != null)
{
KazakhstanRegion region = new();
region.Name = attr.Value!=null ? attr.Value : "Unknown";
foreach (XmlElement XmlregionInfo in Xmlregion)
{
switch (XmlregionInfo.Name)
{
case "GeneralInfo":
region.GeneralInfo = XmlregionInfo.InnerText;
break;
case "Landmarks":
region.Landmarks = new List<Landmark>();
foreach (XmlElement XmlLandmark in XmlregionInfo)
{
XmlNode? attrLandmark = XmlLandmark.Attributes?.GetNamedItem("name");
if (attrLandmark != null)
{
Landmark landmark = new();
landmark.Name = attrLandmark.Value!=null ? attrLandmark.Value : "Unknown";
foreach (XmlElement XmlLandmarkInfo in XmlLandmark)
{
switch (XmlLandmarkInfo.Name)
{
case "Description":
landmark.Description = XmlLandmarkInfo.InnerText;
break;
case "Image":
landmark.Image = XmlLandmarkInfo.InnerText;
break;
case "Location":
landmark.Location = XmlLandmarkInfo.InnerText;
break;
}
}
region.Landmarks.Add(landmark);
}
}
break;
}
}
Regions.Add(region);
}
}
break;
}
}
}
}
public string? API { get; set; }
public string WelcomeMessage { get; set; } = "Failed to load WelcomeMessage";
public string HelpMessage { get; set; } = "Failed to load HelpMessage";
public string GeneralInfo { get; set; } = "Failed to load GeneralInfo";
public string History { get; set; } = "Failed to load History";
public string Geography { get; set; } = "Failed to load Geography";
public string Culture { get; set; } = "Failed to load Culture";
public string Economy { get; set; } = "Failed to load Economy";
public List<KazakhstanRegion> Regions { get; set; } = new();
}
public class KazakhstanRegion
{
public string Name { get; set; } = "Failed to load Name";
public string GeneralInfo { get; set; } = "Failed to load GeneralInfo";
public List<Landmark> Landmarks { get; set; } = new();
}
public class Landmark
{
public string Name { get; set; } = "Failed to load Name";
public string Description { get; set; } = "Failed to load Description";
public string Image { get; set; } = "Failed to load Image";
public string Location { get; set; } = "Failed to load Location";
}