diff options
Diffstat (limited to 'src/internal/TablesAndTuples/WixColumnDefinition.cs')
-rw-r--r-- | src/internal/TablesAndTuples/WixColumnDefinition.cs | 296 |
1 files changed, 296 insertions, 0 deletions
diff --git a/src/internal/TablesAndTuples/WixColumnDefinition.cs b/src/internal/TablesAndTuples/WixColumnDefinition.cs new file mode 100644 index 00000000..2d60c9dc --- /dev/null +++ b/src/internal/TablesAndTuples/WixColumnDefinition.cs | |||
@@ -0,0 +1,296 @@ | |||
1 | using System; | ||
2 | using System.Xml; | ||
3 | |||
4 | namespace TablesAndSymbols | ||
5 | { | ||
6 | class WixColumnDefinition | ||
7 | { | ||
8 | public WixColumnDefinition(string name, ColumnType type, int length, bool primaryKey, bool nullable, ColumnCategory category, long? minValue = null, long? maxValue = null, string keyTable = null, int? keyColumn = null, string possibilities = null, string description = null, ColumnModularizeType? modularizeType = null, bool forceLocalizable = false, bool useCData = false, bool unreal = false) | ||
9 | { | ||
10 | this.Name = name; | ||
11 | this.Type = type; | ||
12 | this.Length = length; | ||
13 | this.PrimaryKey = primaryKey; | ||
14 | this.Nullable = nullable; | ||
15 | this.ModularizeType = modularizeType; | ||
16 | this.ForceLocalizable = forceLocalizable; | ||
17 | this.MinValue = minValue; | ||
18 | this.MaxValue = maxValue; | ||
19 | this.KeyTable = keyTable; | ||
20 | this.KeyColumn = keyColumn; | ||
21 | this.Category = category; | ||
22 | this.Possibilities = possibilities; | ||
23 | this.Description = description; | ||
24 | this.UseCData = useCData; | ||
25 | this.Unreal = unreal; | ||
26 | } | ||
27 | |||
28 | public string Name { get; } | ||
29 | public ColumnType Type { get; } | ||
30 | public int Length { get; } | ||
31 | public bool PrimaryKey { get; } | ||
32 | public bool Nullable { get; } | ||
33 | public ColumnModularizeType? ModularizeType { get; } | ||
34 | public bool ForceLocalizable { get; } | ||
35 | public long? MinValue { get; } | ||
36 | public long? MaxValue { get; } | ||
37 | public string KeyTable { get; } | ||
38 | public int? KeyColumn { get; } | ||
39 | public ColumnCategory Category { get; } | ||
40 | public string Possibilities { get; } | ||
41 | public string Description { get; } | ||
42 | public bool UseCData { get; } | ||
43 | public bool Unreal { get; } | ||
44 | |||
45 | internal static WixColumnDefinition Read(XmlReader reader) | ||
46 | { | ||
47 | if (!reader.LocalName.Equals("columnDefinition")) | ||
48 | { | ||
49 | throw new XmlException(); | ||
50 | } | ||
51 | |||
52 | ColumnCategory category = ColumnCategory.Unknown; | ||
53 | string description = null; | ||
54 | bool empty = reader.IsEmptyElement; | ||
55 | int? keyColumn = null; | ||
56 | string keyTable = null; | ||
57 | int length = -1; | ||
58 | bool localizable = false; | ||
59 | long? maxValue = null; | ||
60 | long? minValue = null; | ||
61 | var modularize = ColumnModularizeType.None; | ||
62 | string name = null; | ||
63 | bool nullable = false; | ||
64 | string possibilities = null; | ||
65 | bool primaryKey = false; | ||
66 | var type = ColumnType.Unknown; | ||
67 | bool useCData = false; | ||
68 | bool unreal = false; | ||
69 | |||
70 | // parse the attributes | ||
71 | while (reader.MoveToNextAttribute()) | ||
72 | { | ||
73 | switch (reader.LocalName) | ||
74 | { | ||
75 | case "category": | ||
76 | switch (reader.Value) | ||
77 | { | ||
78 | case "anyPath": | ||
79 | category = ColumnCategory.AnyPath; | ||
80 | break; | ||
81 | case "binary": | ||
82 | category = ColumnCategory.Binary; | ||
83 | break; | ||
84 | case "cabinet": | ||
85 | category = ColumnCategory.Cabinet; | ||
86 | break; | ||
87 | case "condition": | ||
88 | category = ColumnCategory.Condition; | ||
89 | break; | ||
90 | case "customSource": | ||
91 | category = ColumnCategory.CustomSource; | ||
92 | break; | ||
93 | case "defaultDir": | ||
94 | category = ColumnCategory.DefaultDir; | ||
95 | break; | ||
96 | case "doubleInteger": | ||
97 | category = ColumnCategory.DoubleInteger; | ||
98 | break; | ||
99 | case "filename": | ||
100 | category = ColumnCategory.Filename; | ||
101 | break; | ||
102 | case "formatted": | ||
103 | category = ColumnCategory.Formatted; | ||
104 | break; | ||
105 | case "formattedSddl": | ||
106 | category = ColumnCategory.FormattedSDDLText; | ||
107 | break; | ||
108 | case "guid": | ||
109 | category = ColumnCategory.Guid; | ||
110 | break; | ||
111 | case "identifier": | ||
112 | category = ColumnCategory.Identifier; | ||
113 | break; | ||
114 | case "integer": | ||
115 | category = ColumnCategory.Integer; | ||
116 | break; | ||
117 | case "language": | ||
118 | category = ColumnCategory.Language; | ||
119 | break; | ||
120 | case "lowerCase": | ||
121 | category = ColumnCategory.LowerCase; | ||
122 | break; | ||
123 | case "path": | ||
124 | category = ColumnCategory.Path; | ||
125 | break; | ||
126 | case "paths": | ||
127 | category = ColumnCategory.Paths; | ||
128 | break; | ||
129 | case "property": | ||
130 | category = ColumnCategory.Property; | ||
131 | break; | ||
132 | case "regPath": | ||
133 | category = ColumnCategory.RegPath; | ||
134 | break; | ||
135 | case "shortcut": | ||
136 | category = ColumnCategory.Shortcut; | ||
137 | break; | ||
138 | case "template": | ||
139 | category = ColumnCategory.Template; | ||
140 | break; | ||
141 | case "text": | ||
142 | category = ColumnCategory.Text; | ||
143 | break; | ||
144 | case "timeDate": | ||
145 | category = ColumnCategory.TimeDate; | ||
146 | break; | ||
147 | case "upperCase": | ||
148 | category = ColumnCategory.UpperCase; | ||
149 | break; | ||
150 | case "version": | ||
151 | category = ColumnCategory.Version; | ||
152 | break; | ||
153 | case "wildCardFilename": | ||
154 | category = ColumnCategory.WildCardFilename; | ||
155 | break; | ||
156 | default: | ||
157 | throw new InvalidOperationException(); | ||
158 | } | ||
159 | break; | ||
160 | case "description": | ||
161 | description = reader.Value; | ||
162 | break; | ||
163 | case "keyColumn": | ||
164 | keyColumn = Convert.ToInt32(reader.Value, 10); | ||
165 | break; | ||
166 | case "keyTable": | ||
167 | keyTable = reader.Value; | ||
168 | break; | ||
169 | case "length": | ||
170 | length = Convert.ToInt32(reader.Value, 10); | ||
171 | break; | ||
172 | case "localizable": | ||
173 | localizable = reader.Value.Equals("yes"); | ||
174 | break; | ||
175 | case "maxValue": | ||
176 | maxValue = Convert.ToInt32(reader.Value, 10); | ||
177 | break; | ||
178 | case "minValue": | ||
179 | minValue = Convert.ToInt32(reader.Value, 10); | ||
180 | break; | ||
181 | case "modularize": | ||
182 | switch (reader.Value) | ||
183 | { | ||
184 | case "column": | ||
185 | modularize = ColumnModularizeType.Column; | ||
186 | break; | ||
187 | case "companionFile": | ||
188 | modularize = ColumnModularizeType.CompanionFile; | ||
189 | break; | ||
190 | case "condition": | ||
191 | modularize = ColumnModularizeType.Condition; | ||
192 | break; | ||
193 | case "controlEventArgument": | ||
194 | modularize = ColumnModularizeType.ControlEventArgument; | ||
195 | break; | ||
196 | case "controlText": | ||
197 | modularize = ColumnModularizeType.ControlText; | ||
198 | break; | ||
199 | case "icon": | ||
200 | modularize = ColumnModularizeType.Icon; | ||
201 | break; | ||
202 | case "none": | ||
203 | modularize = ColumnModularizeType.None; | ||
204 | break; | ||
205 | case "property": | ||
206 | modularize = ColumnModularizeType.Property; | ||
207 | break; | ||
208 | case "semicolonDelimited": | ||
209 | modularize = ColumnModularizeType.SemicolonDelimited; | ||
210 | break; | ||
211 | default: | ||
212 | throw new XmlException(); | ||
213 | } | ||
214 | break; | ||
215 | case "name": | ||
216 | switch (reader.Value) | ||
217 | { | ||
218 | case "CREATE": | ||
219 | case "DELETE": | ||
220 | case "DROP": | ||
221 | case "INSERT": | ||
222 | throw new XmlException(); | ||
223 | default: | ||
224 | name = reader.Value; | ||
225 | break; | ||
226 | } | ||
227 | break; | ||
228 | case "nullable": | ||
229 | nullable = reader.Value.Equals("yes"); | ||
230 | break; | ||
231 | case "primaryKey": | ||
232 | primaryKey = reader.Value.Equals("yes"); | ||
233 | break; | ||
234 | case "set": | ||
235 | possibilities = reader.Value; | ||
236 | break; | ||
237 | case "type": | ||
238 | switch (reader.Value) | ||
239 | { | ||
240 | case "localized": | ||
241 | type = ColumnType.Localized; | ||
242 | break; | ||
243 | case "number": | ||
244 | type = ColumnType.Number; | ||
245 | break; | ||
246 | case "object": | ||
247 | type = ColumnType.Object; | ||
248 | break; | ||
249 | case "string": | ||
250 | type = ColumnType.String; | ||
251 | break; | ||
252 | case "preserved": | ||
253 | type = ColumnType.Preserved; | ||
254 | break; | ||
255 | default: | ||
256 | throw new XmlException(); | ||
257 | } | ||
258 | break; | ||
259 | case "useCData": | ||
260 | useCData = reader.Value.Equals("yes"); | ||
261 | break; | ||
262 | case "unreal": | ||
263 | unreal = reader.Value.Equals("yes"); | ||
264 | break; | ||
265 | } | ||
266 | } | ||
267 | |||
268 | // parse the child elements (there should be none) | ||
269 | if (!empty) | ||
270 | { | ||
271 | bool done = false; | ||
272 | |||
273 | while (!done && reader.Read()) | ||
274 | { | ||
275 | switch (reader.NodeType) | ||
276 | { | ||
277 | case XmlNodeType.Element: | ||
278 | throw new XmlException(); | ||
279 | case XmlNodeType.EndElement: | ||
280 | done = true; | ||
281 | break; | ||
282 | } | ||
283 | } | ||
284 | |||
285 | if (!done) | ||
286 | { | ||
287 | throw new XmlException(); | ||
288 | } | ||
289 | } | ||
290 | |||
291 | WixColumnDefinition columnDefinition = new WixColumnDefinition(name, type, length, primaryKey, nullable, category, minValue, maxValue, keyTable, keyColumn, possibilities, description, modularize, localizable, useCData, unreal); | ||
292 | |||
293 | return columnDefinition; | ||
294 | } | ||
295 | } | ||
296 | } | ||