diff options
Diffstat (limited to 'src/WixToolset.Data.WindowsInstaller/Rows/WixActionRow.cs')
-rw-r--r-- | src/WixToolset.Data.WindowsInstaller/Rows/WixActionRow.cs | 378 |
1 files changed, 0 insertions, 378 deletions
diff --git a/src/WixToolset.Data.WindowsInstaller/Rows/WixActionRow.cs b/src/WixToolset.Data.WindowsInstaller/Rows/WixActionRow.cs deleted file mode 100644 index d1be706e..00000000 --- a/src/WixToolset.Data.WindowsInstaller/Rows/WixActionRow.cs +++ /dev/null | |||
@@ -1,378 +0,0 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolset.Data.Rows | ||
4 | { | ||
5 | using System; | ||
6 | using System.Collections.Generic; | ||
7 | using System.Diagnostics; | ||
8 | using System.Globalization; | ||
9 | using System.Xml; | ||
10 | using System.Xml.Schema; | ||
11 | using WixToolset.Data.Tuples; | ||
12 | |||
13 | /// <summary> | ||
14 | /// The Sequence tables that actions may belong to. | ||
15 | /// </summary> | ||
16 | //public enum SequenceTable | ||
17 | //{ | ||
18 | // /// <summary>AdminUISequence</summary> | ||
19 | // AdminUISequence, | ||
20 | |||
21 | // /// <summary>AdminExecuteSequence</summary> | ||
22 | // AdminExecuteSequence, | ||
23 | |||
24 | // /// <summary>AdvtExecuteSequence</summary> | ||
25 | // AdvtExecuteSequence, | ||
26 | |||
27 | // /// <summary>InstallUISequence</summary> | ||
28 | // InstallUISequence, | ||
29 | |||
30 | // /// <summary>InstallExecuteSequence</summary> | ||
31 | // InstallExecuteSequence | ||
32 | //} | ||
33 | |||
34 | /// <summary> | ||
35 | /// Specialization of a row for the sequence tables. | ||
36 | /// </summary> | ||
37 | public sealed class WixActionRow : Row, IComparable | ||
38 | { | ||
39 | private WixActionRowCollection previousActionRows; | ||
40 | private WixActionRowCollection nextActionRows; | ||
41 | |||
42 | /// <summary> | ||
43 | /// Instantiates an ActionRow that belongs to a table. | ||
44 | /// </summary> | ||
45 | /// <param name="sourceLineNumbers">Original source lines for this row.</param> | ||
46 | /// <param name="table">Table this Action row belongs to and should get its column definitions from.</param> | ||
47 | public WixActionRow(SourceLineNumber sourceLineNumbers, Table table) : | ||
48 | base(sourceLineNumbers, table) | ||
49 | { | ||
50 | } | ||
51 | |||
52 | /// <summary> | ||
53 | /// Instantiates a standard ActionRow. | ||
54 | /// </summary> | ||
55 | /// <param name="sequenceTable">The sequence table of the standard action.</param> | ||
56 | /// <param name="action">The name of the standard action.</param> | ||
57 | /// <param name="condition">The condition of the standard action.</param> | ||
58 | /// <param name="sequence">The suggested sequence number of the standard action.</param> | ||
59 | //private WixActionRow(SequenceTable sequenceTable, string action, string condition, int sequence) : | ||
60 | // base(null, WindowsInstallerStandard.GetTableDefinitions()["WixAction"]) | ||
61 | //{ | ||
62 | // this.SequenceTable = sequenceTable; | ||
63 | // this.Action = action; | ||
64 | // this.Condition = condition; | ||
65 | // this.Sequence = sequence; | ||
66 | // this.Overridable = true; // all standard actions are overridable by default | ||
67 | //} | ||
68 | |||
69 | /// <summary> | ||
70 | /// Instantiates an ActionRow by copying data from another ActionRow. | ||
71 | /// </summary> | ||
72 | /// <param name="source">The row the data is copied from.</param> | ||
73 | /// <remarks>The previous and next action collections are not copied.</remarks> | ||
74 | private WixActionRow(WixActionRow source) | ||
75 | : base(source) | ||
76 | { | ||
77 | } | ||
78 | |||
79 | /// <summary> | ||
80 | /// Gets or sets the name of the action. | ||
81 | /// </summary> | ||
82 | /// <value>The name of the action.</value> | ||
83 | public string Action | ||
84 | { | ||
85 | get { return (string)this.Fields[1].Data; } | ||
86 | set { this.Fields[1].Data = value; } | ||
87 | } | ||
88 | |||
89 | /// <summary> | ||
90 | /// Gets the name of the action this action should be scheduled after. | ||
91 | /// </summary> | ||
92 | /// <value>The name of the action this action should be scheduled after.</value> | ||
93 | public string After | ||
94 | { | ||
95 | get { return (string)this.Fields[5].Data; } | ||
96 | set { this.Fields[5].Data = value; } | ||
97 | } | ||
98 | |||
99 | /// <summary> | ||
100 | /// Gets the name of the action this action should be scheduled before. | ||
101 | /// </summary> | ||
102 | /// <value>The name of the action this action should be scheduled before.</value> | ||
103 | public string Before | ||
104 | { | ||
105 | get { return (string)this.Fields[4].Data; } | ||
106 | set { this.Fields[4].Data = value; } | ||
107 | } | ||
108 | |||
109 | /// <summary> | ||
110 | /// Gets or sets the condition of the action. | ||
111 | /// </summary> | ||
112 | /// <value>The condition of the action.</value> | ||
113 | public string Condition | ||
114 | { | ||
115 | get { return (string)this.Fields[2].Data; } | ||
116 | set { this.Fields[2].Data = value; } | ||
117 | } | ||
118 | |||
119 | /// <summary> | ||
120 | /// Gets or sets whether this action is overridable. | ||
121 | /// </summary> | ||
122 | /// <value>Whether this action is overridable.</value> | ||
123 | public bool Overridable | ||
124 | { | ||
125 | get { return (1 == Convert.ToInt32(this.Fields[6].Data, CultureInfo.InvariantCulture)); } | ||
126 | set { this.Fields[6].Data = (value ? 1 : 0); } | ||
127 | } | ||
128 | |||
129 | /// <summary> | ||
130 | /// Gets or sets the sequence number of this action. | ||
131 | /// </summary> | ||
132 | /// <value>The sequence number of this action.</value> | ||
133 | public int Sequence | ||
134 | { | ||
135 | get { return Convert.ToInt32(this.Fields[3].Data, CultureInfo.InvariantCulture); } | ||
136 | set { this.Fields[3].Data = value; } | ||
137 | } | ||
138 | |||
139 | /// <summary> | ||
140 | /// Gets of sets the sequence table of this action. | ||
141 | /// </summary> | ||
142 | /// <value>The sequence table of this action.</value> | ||
143 | public SequenceTable SequenceTable | ||
144 | { | ||
145 | get { return (SequenceTable)Enum.Parse(typeof(SequenceTable), (string)this.Fields[0].Data); } | ||
146 | set { this.Fields[0].Data = value.ToString(); } | ||
147 | } | ||
148 | |||
149 | /// <summary> | ||
150 | /// Gets the actions that should be scheduled after this action. | ||
151 | /// </summary> | ||
152 | /// <value>The actions that should be scheduled after this action.</value> | ||
153 | public WixActionRowCollection NextActionRows | ||
154 | { | ||
155 | get | ||
156 | { | ||
157 | if (null == this.nextActionRows) | ||
158 | { | ||
159 | this.nextActionRows = new WixActionRowCollection(); | ||
160 | } | ||
161 | |||
162 | return this.nextActionRows; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | /// <summary> | ||
167 | /// Gets the actions that should be scheduled before this action. | ||
168 | /// </summary> | ||
169 | /// <value>The actions that should be scheduled before this action.</value> | ||
170 | public WixActionRowCollection PreviousActionRows | ||
171 | { | ||
172 | get | ||
173 | { | ||
174 | if (null == this.previousActionRows) | ||
175 | { | ||
176 | this.previousActionRows = new WixActionRowCollection(); | ||
177 | } | ||
178 | |||
179 | return this.previousActionRows; | ||
180 | } | ||
181 | } | ||
182 | |||
183 | /// <summary> | ||
184 | /// Creates a clone of the action row. | ||
185 | /// </summary> | ||
186 | /// <returns>A shallow copy of the source object.</returns> | ||
187 | /// <remarks>The previous and next action collections are not copied.</remarks> | ||
188 | public WixActionRow Clone() | ||
189 | { | ||
190 | return new WixActionRow(this); | ||
191 | } | ||
192 | |||
193 | /// <summary> | ||
194 | /// Compares the current instance with another object of the same type. | ||
195 | /// </summary> | ||
196 | /// <param name="obj">Other reference to compare this one to.</param> | ||
197 | /// <returns>Returns less than 0 for less than, 0 for equals, and greater than 0 for greater.</returns> | ||
198 | public int CompareTo(object obj) | ||
199 | { | ||
200 | WixActionRow otherActionRow = (WixActionRow)obj; | ||
201 | |||
202 | return this.Sequence.CompareTo(otherActionRow.Sequence); | ||
203 | } | ||
204 | |||
205 | /// <summary> | ||
206 | /// Parses ActionRows from the Xml reader. | ||
207 | /// </summary> | ||
208 | /// <param name="reader">Xml reader that contains serialized ActionRows.</param> | ||
209 | /// <returns>The parsed ActionRows.</returns> | ||
210 | internal static WixActionRow[] Parse(XmlReader reader) | ||
211 | { | ||
212 | Debug.Assert("action" == reader.LocalName); | ||
213 | |||
214 | string id = null; | ||
215 | string condition = null; | ||
216 | bool empty = reader.IsEmptyElement; | ||
217 | int sequence = int.MinValue; | ||
218 | int sequenceCount = 0; | ||
219 | SequenceTable[] sequenceTables = new SequenceTable[Enum.GetValues(typeof(SequenceTable)).Length]; | ||
220 | |||
221 | while (reader.MoveToNextAttribute()) | ||
222 | { | ||
223 | switch (reader.Name) | ||
224 | { | ||
225 | case "name": | ||
226 | id = reader.Value; | ||
227 | break; | ||
228 | case "AdminExecuteSequence": | ||
229 | if (reader.Value.Equals("yes")) | ||
230 | { | ||
231 | sequenceTables[sequenceCount] = SequenceTable.AdminExecuteSequence; | ||
232 | ++sequenceCount; | ||
233 | } | ||
234 | break; | ||
235 | case "AdminUISequence": | ||
236 | if (reader.Value.Equals("yes")) | ||
237 | { | ||
238 | sequenceTables[sequenceCount] = SequenceTable.AdminUISequence; | ||
239 | ++sequenceCount; | ||
240 | } | ||
241 | break; | ||
242 | case "AdvtExecuteSequence": | ||
243 | if (reader.Value.Equals("yes")) | ||
244 | { | ||
245 | sequenceTables[sequenceCount] = SequenceTable.AdvtExecuteSequence; | ||
246 | ++sequenceCount; | ||
247 | } | ||
248 | break; | ||
249 | case "condition": | ||
250 | condition = reader.Value; | ||
251 | break; | ||
252 | case "InstallExecuteSequence": | ||
253 | if (reader.Value.Equals("yes")) | ||
254 | { | ||
255 | sequenceTables[sequenceCount] = SequenceTable.InstallExecuteSequence; | ||
256 | ++sequenceCount; | ||
257 | } | ||
258 | break; | ||
259 | case "InstallUISequence": | ||
260 | if (reader.Value.Equals("yes")) | ||
261 | { | ||
262 | sequenceTables[sequenceCount] = SequenceTable.InstallUISequence; | ||
263 | ++sequenceCount; | ||
264 | } | ||
265 | break; | ||
266 | case "sequence": | ||
267 | sequence = Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture); | ||
268 | break; | ||
269 | } | ||
270 | } | ||
271 | |||
272 | if (null == id) | ||
273 | { | ||
274 | throw new XmlException(); | ||
275 | } | ||
276 | |||
277 | if (int.MinValue == sequence) | ||
278 | { | ||
279 | throw new XmlException(); | ||
280 | } | ||
281 | else if (1 > sequence) | ||
282 | { | ||
283 | throw new XmlException(); | ||
284 | } | ||
285 | |||
286 | if (0 == sequenceCount) | ||
287 | { | ||
288 | throw new XmlException(); | ||
289 | } | ||
290 | |||
291 | if (!empty && reader.Read() && XmlNodeType.EndElement != reader.MoveToContent()) | ||
292 | { | ||
293 | throw new XmlException(); | ||
294 | } | ||
295 | |||
296 | // create the actions | ||
297 | WixActionRow[] actionRows = new WixActionRow[sequenceCount]; | ||
298 | for (int i = 0; i < sequenceCount; i++) | ||
299 | { | ||
300 | //WixActionRow actionRow = new WixActionRow(sequenceTables[i], id, condition, sequence); | ||
301 | //actionRows[i] = actionRow; | ||
302 | throw new NotImplementedException(); | ||
303 | } | ||
304 | |||
305 | return actionRows; | ||
306 | } | ||
307 | |||
308 | #if DEAD_CODE | ||
309 | /// <summary> | ||
310 | /// Determines whether this ActionRow contains the specified ActionRow as a child in its dependency tree. | ||
311 | /// </summary> | ||
312 | /// <param name="actionRow">The possible child ActionRow.</param> | ||
313 | /// <returns>true if the ActionRow is a child of this ActionRow; false otherwise.</returns> | ||
314 | public bool ContainsChildActionRow(WixActionRow actionRow) | ||
315 | { | ||
316 | if (null != this.previousActionRows) | ||
317 | { | ||
318 | if (this.previousActionRows.Contains(actionRow.SequenceTable, actionRow.Action)) | ||
319 | { | ||
320 | return true; | ||
321 | } | ||
322 | } | ||
323 | |||
324 | if (null != this.nextActionRows) | ||
325 | { | ||
326 | if (this.nextActionRows.Contains(actionRow.SequenceTable, actionRow.Action)) | ||
327 | { | ||
328 | return true; | ||
329 | } | ||
330 | } | ||
331 | |||
332 | return false; | ||
333 | } | ||
334 | |||
335 | /// <summary> | ||
336 | /// Get all the actions scheduled before this one in a particular sequence table. | ||
337 | /// </summary> | ||
338 | /// <param name="sequenceTable">The sequence table.</param> | ||
339 | /// <param name="allPreviousActionRows">A RowCollection which will contain all the previous actions.</param> | ||
340 | public void GetAllPreviousActionRows(SequenceTable sequenceTable, IList<WixActionRow> allPreviousActionRows) | ||
341 | { | ||
342 | if (null != this.previousActionRows) | ||
343 | { | ||
344 | foreach (WixActionRow actionRow in this.previousActionRows) | ||
345 | { | ||
346 | if (sequenceTable == actionRow.SequenceTable) | ||
347 | { | ||
348 | actionRow.GetAllPreviousActionRows(sequenceTable, allPreviousActionRows); | ||
349 | allPreviousActionRows.Add(actionRow); | ||
350 | actionRow.GetAllNextActionRows(sequenceTable, allPreviousActionRows); | ||
351 | } | ||
352 | } | ||
353 | } | ||
354 | } | ||
355 | |||
356 | /// <summary> | ||
357 | /// Get all the actions scheduled after this one in a particular sequence table. | ||
358 | /// </summary> | ||
359 | /// <param name="sequenceTable">The sequence table.</param> | ||
360 | /// <param name="allNextActionRows">A RowCollection which will contain all the next actions.</param> | ||
361 | public void GetAllNextActionRows(SequenceTable sequenceTable, IList<WixActionRow> allNextActionRows) | ||
362 | { | ||
363 | if (null != this.nextActionRows) | ||
364 | { | ||
365 | foreach (WixActionRow actionRow in this.nextActionRows) | ||
366 | { | ||
367 | if (sequenceTable == actionRow.SequenceTable) | ||
368 | { | ||
369 | actionRow.GetAllPreviousActionRows(sequenceTable, allNextActionRows); | ||
370 | allNextActionRows.Add(actionRow); | ||
371 | actionRow.GetAllNextActionRows(sequenceTable, allNextActionRows); | ||
372 | } | ||
373 | } | ||
374 | } | ||
375 | } | ||
376 | #endif | ||
377 | } | ||
378 | } | ||