Repository navigation
Expand file tree
/
Copy pathWIMInformationXML.cs
More file actions
251 lines (196 loc) · 8.26 KB
/
Copy pathWIMInformationXML.cs
File metadata and controls
251 lines (196 loc) · 8.26 KB
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
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
namespace Imaging
{
public class WIMInformationXML
{
[XmlRoot(ElementName = "CREATIONTIME")]
public class CREATIONTIME
{
[XmlElement(ElementName = "HIGHPART")]
public string HIGHPART { get; set; }
[XmlElement(ElementName = "LOWPART")]
public string LOWPART { get; set; }
}
[XmlRoot(ElementName = "LASTMODIFICATIONTIME")]
public class LASTMODIFICATIONTIME
{
[XmlElement(ElementName = "HIGHPART")]
public string HIGHPART { get; set; }
[XmlElement(ElementName = "LOWPART")]
public string LOWPART { get; set; }
}
[XmlRoot(ElementName = "SERVICINGDATA")]
public class SERVICINGDATA
{
[XmlElement(ElementName = "GDRDUREVISION")]
public string GDRDUREVISION { get; set; }
[XmlElement(ElementName = "PKEYCONFIGVERSION")]
public string PKEYCONFIGVERSION { get; set; }
[XmlElement(ElementName = "IMAGESTATE")]
public string IMAGESTATE { get; set; }
}
[XmlRoot(ElementName = "FALLBACK")]
public class FALLBACK
{
[XmlAttribute(AttributeName = "LANGUAGE")]
public string LANGUAGE { get; set; }
[XmlText]
public string Text { get; set; }
}
[XmlRoot(ElementName = "LANGUAGES")]
public class LANGUAGES
{
[XmlElement(ElementName = "LANGUAGE")]
public string LANGUAGE { get; set; }
[XmlElement(ElementName = "FALLBACK")]
public FALLBACK FALLBACK { get; set; }
[XmlElement(ElementName = "DEFAULT")]
public string DEFAULT { get; set; }
}
[XmlRoot(ElementName = "VERSION")]
public class VERSION
{
[XmlElement(ElementName = "MAJOR")]
public string MAJOR { get; set; }
[XmlElement(ElementName = "MINOR")]
public string MINOR { get; set; }
[XmlElement(ElementName = "BUILD")]
public string BUILD { get; set; }
[XmlElement(ElementName = "SPBUILD")]
public string SPBUILD { get; set; }
[XmlElement(ElementName = "SPLEVEL")]
public string SPLEVEL { get; set; }
[XmlElement(ElementName = "BRANCH")]
public string BRANCH { get; set; }
}
[XmlRoot(ElementName = "WINDOWS")]
public class WINDOWS
{
[XmlElement(ElementName = "ARCH")]
public string ARCH { get; set; }
[XmlElement(ElementName = "PRODUCTNAME")]
public string PRODUCTNAME { get; set; }
[XmlElement(ElementName = "EDITIONID")]
public string EDITIONID { get; set; }
[XmlElement(ElementName = "INSTALLATIONTYPE")]
public string INSTALLATIONTYPE { get; set; }
[XmlElement(ElementName = "SERVICINGDATA")]
public SERVICINGDATA SERVICINGDATA { get; set; }
[XmlElement(ElementName = "PRODUCTTYPE")]
public string PRODUCTTYPE { get; set; }
[XmlElement(ElementName = "PRODUCTSUITE")]
public string PRODUCTSUITE { get; set; }
[XmlElement(ElementName = "LANGUAGES")]
public LANGUAGES LANGUAGES { get; set; }
[XmlElement(ElementName = "VERSION")]
public VERSION VERSION { get; set; }
[XmlElement(ElementName = "SYSTEMROOT")]
public string SYSTEMROOT { get; set; }
}
[XmlRoot(ElementName = "IMAGE")]
public class IMAGE
{
[XmlElement(ElementName = "DIRCOUNT")]
public string DIRCOUNT { get; set; }
[XmlElement(ElementName = "FILECOUNT")]
public string FILECOUNT { get; set; }
[XmlElement(ElementName = "TOTALBYTES")]
public string TOTALBYTES { get; set; }
[XmlElement(ElementName = "HARDLINKBYTES")]
public string HARDLINKBYTES { get; set; }
[XmlElement(ElementName = "CREATIONTIME")]
public CREATIONTIME CREATIONTIME { get; set; }
[XmlElement(ElementName = "LASTMODIFICATIONTIME")]
public LASTMODIFICATIONTIME LASTMODIFICATIONTIME { get; set; }
[XmlElement(ElementName = "WIMBOOT")]
public string WIMBOOT { get; set; }
[XmlElement(ElementName = "WINDOWS")]
public WINDOWS WINDOWS { get; set; }
[XmlElement(ElementName = "FLAGS")]
public string FLAGS { get; set; }
[XmlElement(ElementName = "DISPLAYNAME")]
public string DISPLAYNAME { get; set; }
[XmlElement(ElementName = "DISPLAYDESCRIPTION")]
public string DISPLAYDESCRIPTION { get; set; }
[XmlElement(ElementName = "NAME")]
public string NAME { get; set; }
[XmlElement(ElementName = "DESCRIPTION")]
public string DESCRIPTION { get; set; }
[XmlAttribute(AttributeName = "INDEX")]
public string INDEX { get; set; }
}
[XmlRoot(ElementName = "WIM")]
public class WIM
{
[XmlElement(ElementName = "TOTALBYTES")]
public string TOTALBYTES { get; set; }
[XmlElement(ElementName = "IMAGE")]
public List<IMAGE> IMAGE { get; set; }
}
public static string SerializeWIM(WIM wim)
{
if (wim == null) return string.Empty;
var xmlSerializer = new XmlSerializer(typeof(WIM));
using (var stringWriter = new StringWriter())
{
using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings
{
Indent = false,
IndentChars = "",
NewLineChars = "",
NewLineHandling = NewLineHandling.None,
OmitXmlDeclaration = true,
NewLineOnAttributes = false
}))
{
xmlSerializer.Serialize(xmlWriter, wim);
return stringWriter.ToString().Replace(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"", "")
.Replace(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"", "");
}
}
}
public static WIM DeserializeWIM(string wim)
{
if (wim == null) return null;
var xmlSerializer = new XmlSerializer(typeof(WIM));
using (var stringReader = new StringReader(wim))
{
return (WIM)xmlSerializer.Deserialize(stringReader);
}
}
public static string SerializeIMAGE(IMAGE wim)
{
if (wim == null) return string.Empty;
var xmlSerializer = new XmlSerializer(typeof(IMAGE));
using (var stringWriter = new StringWriter())
{
using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings
{
Indent = false,
IndentChars = "",
NewLineChars = "",
NewLineHandling = NewLineHandling.None,
OmitXmlDeclaration = true,
NewLineOnAttributes = false
}))
{
xmlSerializer.Serialize(xmlWriter, wim);
return stringWriter.ToString().Replace(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"", "")
.Replace(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"", "");
}
}
}
public static IMAGE DeserializeIMAGE(string wim)
{
if (wim == null) return null;
var xmlSerializer = new XmlSerializer(typeof(IMAGE));
using (var stringReader = new StringReader(wim))
{
return (IMAGE)xmlSerializer.Deserialize(stringReader);
}
}
}
}