@joebigelow / wix / commits / 6e2e67ab

Remove WixActionRowCollection and duplicate actions.xml

Rob Mensching committed Jan 13, 2020 at 14:41 UTC 6e2e67ab55c75f4655397588c0dcc64f50d22f92
7 files changed +63 -496
src/WixToolset.Core.WindowsInstaller/Bind/CopyTransformDataCommand.cs
+42 -37
@@ -433,59 +433,63 @@ namespace WixToolset.Core.WindowsInstaller.Bind
433 /// <param name="mainFileRow">The file row that contains information about the patched file.</param>
434 private void AddPatchFilesActionToSequenceTable(SequenceTable table, WindowsInstallerData mainTransform, WindowsInstallerData pairedTransform, Row mainFileRow)
435 {
436 + var tableName = table.ToString();
437 +
438 // Find/add PatchFiles action (also determine sequence for it).
439 // Search mainTransform first, then pairedTransform (pairedTransform overrides).
438 - bool hasPatchFilesAction = false;
439 - int seqInstallFiles = 0;
440 - int seqDuplicateFiles = 0;
441 - string tableName = table.ToString();
440 + var hasPatchFilesAction = false;
441 + var installFilesSequence = 0;
442 + var duplicateFilesSequence = 0;
443
444 TestSequenceTableForPatchFilesAction(
445 mainTransform.Tables[tableName],
446 ref hasPatchFilesAction,
446 - ref seqInstallFiles,
447 - ref seqDuplicateFiles);
447 + ref installFilesSequence,
448 + ref duplicateFilesSequence);
449 TestSequenceTableForPatchFilesAction(
450 pairedTransform.Tables[tableName],
451 ref hasPatchFilesAction,
451 - ref seqInstallFiles,
452 - ref seqDuplicateFiles);
452 + ref installFilesSequence,
453 + ref duplicateFilesSequence);
454 if (!hasPatchFilesAction)
455 {
455 - Table iesTable = pairedTransform.EnsureTable(this.TableDefinitions[tableName]);
456 - if (0 == iesTable.Rows.Count)
457 - {
458 - iesTable.Operation = TableOperation.Add;
459 - }
456 + WindowsInstallerStandard.TryGetStandardAction(tableName, "PatchFiles", out var patchFilesActionTuple);
457 +
458 + var sequence = patchFilesActionTuple.Sequence;
459
461 - Row patchAction = iesTable.CreateRow(null);
462 - WixActionRow wixPatchAction = WindowsInstallerStandardInternal.GetStandardActionRows()[table, "PatchFiles"];
463 - int sequence = wixPatchAction.Sequence;
460 // Test for default sequence value's appropriateness
465 - if (seqInstallFiles >= sequence || (0 != seqDuplicateFiles && seqDuplicateFiles <= sequence))
461 + if (installFilesSequence >= sequence || (0 != duplicateFilesSequence && duplicateFilesSequence <= sequence))
462 {
467 - if (0 != seqDuplicateFiles)
463 + if (0 != duplicateFilesSequence)
464 {
469 - if (seqDuplicateFiles < seqInstallFiles)
465 + if (duplicateFilesSequence < installFilesSequence)
466 {
471 - throw new WixException(ErrorMessages.InsertInvalidSequenceActionOrder(mainFileRow.SourceLineNumbers, iesTable.Name, "InstallFiles", "DuplicateFiles", wixPatchAction.Action));
467 + throw new WixException(ErrorMessages.InsertInvalidSequenceActionOrder(mainFileRow.SourceLineNumbers, tableName, "InstallFiles", "DuplicateFiles", patchFilesActionTuple.Action));
468 }
469 else
470 {
475 - sequence = (seqDuplicateFiles + seqInstallFiles) / 2;
476 - if (seqInstallFiles == sequence || seqDuplicateFiles == sequence)
471 + sequence = (duplicateFilesSequence + installFilesSequence) / 2;
472 + if (installFilesSequence == sequence || duplicateFilesSequence == sequence)
473 {
478 - throw new WixException(ErrorMessages.InsertSequenceNoSpace(mainFileRow.SourceLineNumbers, iesTable.Name, "InstallFiles", "DuplicateFiles", wixPatchAction.Action));
474 + throw new WixException(ErrorMessages.InsertSequenceNoSpace(mainFileRow.SourceLineNumbers, tableName, "InstallFiles", "DuplicateFiles", patchFilesActionTuple.Action));
475 }
476 }
477 }
478 else
479 {
484 - sequence = seqInstallFiles + 1;
480 + sequence = installFilesSequence + 1;
481 }
482 }
487 - patchAction[0] = wixPatchAction.Action;
488 - patchAction[1] = wixPatchAction.Condition;
483 +
484 + var sequenceTable = pairedTransform.EnsureTable(this.TableDefinitions[tableName]);
485 + if (0 == sequenceTable.Rows.Count)
486 + {
487 + sequenceTable.Operation = TableOperation.Add;
488 + }
489 +
490 + var patchAction = sequenceTable.CreateRow(null);
491 + patchAction[0] = patchFilesActionTuple.Action;
492 + patchAction[1] = patchFilesActionTuple.Condition;
493 patchAction[2] = sequence;
494 patchAction.Operation = RowOperation.Add;
495 }
@@ -494,27 +498,28 @@ namespace WixToolset.Core.WindowsInstaller.Bind
498 /// <summary>
499 /// Tests sequence table for PatchFiles and associated actions
500 /// </summary>
497 - /// <param name="iesTable">The table to test.</param>
501 + /// <param name="sequenceTable">The table to test.</param>
502 /// <param name="hasPatchFilesAction">Set to true if PatchFiles action is found. Left unchanged otherwise.</param>
499 - /// <param name="seqInstallFiles">Set to sequence value of InstallFiles action if found. Left unchanged otherwise.</param>
500 - /// <param name="seqDuplicateFiles">Set to sequence value of DuplicateFiles action if found. Left unchanged otherwise.</param>
501 - private static void TestSequenceTableForPatchFilesAction(Table iesTable, ref bool hasPatchFilesAction, ref int seqInstallFiles, ref int seqDuplicateFiles)
503 + /// <param name="installFilesSequence">Set to sequence value of InstallFiles action if found. Left unchanged otherwise.</param>
504 + /// <param name="duplicateFilesSequence">Set to sequence value of DuplicateFiles action if found. Left unchanged otherwise.</param>
505 + private static void TestSequenceTableForPatchFilesAction(Table sequenceTable, ref bool hasPatchFilesAction, ref int installFilesSequence, ref int duplicateFilesSequence)
506 {
503 - if (null != iesTable)
507 + if (null != sequenceTable)
508 {
505 - foreach (Row iesRow in iesTable.Rows)
509 + foreach (var row in sequenceTable.Rows)
510 {
507 - if (String.Equals("PatchFiles", (string)iesRow[0], StringComparison.Ordinal))
511 + var actionName = row.FieldAsString(0);
512 + if (String.Equals("PatchFiles", actionName, StringComparison.Ordinal))
513 {
514 hasPatchFilesAction = true;
515 }
511 - if (String.Equals("InstallFiles", (string)iesRow[0], StringComparison.Ordinal))
516 + else if (String.Equals("InstallFiles", actionName, StringComparison.Ordinal))
517 {
513 - seqInstallFiles = (int)iesRow.Fields[2].Data;
518 + installFilesSequence = row.FieldAsInteger(2);
519 }
515 - if (String.Equals("DuplicateFiles", (string)iesRow[0], StringComparison.Ordinal))
520 + else if (String.Equals("DuplicateFiles", actionName, StringComparison.Ordinal))
521 {
517 - seqDuplicateFiles = (int)iesRow.Fields[2].Data;
522 + duplicateFilesSequence = row.FieldAsInteger(2);
523 }
524 }
525 }
src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
+4 -9
@@ -18,16 +18,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind
18 this.Section = section;
19
20 this.RelativeActionsForActions = new Dictionary<string, RelativeActions>();
21 -
22 - this.StandardActionsById = WindowsInstallerStandard.StandardActions().ToDictionary(a => a.Id.Id);
21 }
22
23 private IntermediateSection Section { get; }
24
25 private Dictionary<string, RelativeActions> RelativeActionsForActions { get; }
26
29 - private Dictionary<string, WixActionTuple> StandardActionsById { get; }
30 -
27 public IMessaging Messaging { private get; set; }
28
29 /// <summary>
@@ -63,7 +59,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
59 // Unsequenced action (allowed for certain standard actions).
60 if (null == actionTuple.Before && null == actionTuple.After && !actionTuple.Sequence.HasValue)
61 {
66 - if (this.StandardActionsById.TryGetValue(actionTuple.Id.Id, out var standardAction))
62 + if (WindowsInstallerStandard.TryGetStandardAction(actionTuple.Id.Id, out var standardAction))
63 {
64 // Populate the sequence from the standard action
65 actionTuple.Sequence = standardAction.Sequence;
@@ -154,7 +150,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
150 // on the presence of a particular table.
151 if (requiredActionTuples.ContainsKey("InstallExecuteSequence/DuplicateFiles") && !requiredActionTuples.ContainsKey("InstallExecuteSequence/InstallFiles"))
152 {
157 - var standardAction = this.StandardActionsById["InstallExecuteSequence/InstallFiles"];
153 + WindowsInstallerStandard.TryGetStandardAction("InstallExecuteSequence/InstallFiles", out var standardAction);
154 requiredActionTuples.Add(standardAction.Id.Id, standardAction);
155 }
156
@@ -201,8 +197,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
197
198 foreach (var actionId in requiredActionIds)
199 {
204 - var standardAction = this.StandardActionsById[actionId];
205 -
200 + WindowsInstallerStandard.TryGetStandardAction(actionId, out var standardAction);
201 overridableActionTuples.Add(standardAction.Id.Id, standardAction);
202 }
203
@@ -597,7 +592,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
592 if (!requiredActionTuples.TryGetValue(parentActionKey, out var parentActionTuple))
593 {
594 // If the missing parent action is a standard action (with a suggested sequence number), add it.
600 - if (this.StandardActionsById.TryGetValue(parentActionKey, out parentActionTuple))
595 + if (WindowsInstallerStandard.TryGetStandardAction(parentActionKey, out parentActionTuple))
596 {
597 // Create a clone to avoid modifying the static copy of the object.
598 // TODO: consider this: parentActionTuple = parentActionTuple.Clone();
src/WixToolset.Core.WindowsInstaller/Data/actions.xml deleted
-76
@@ -1,76 +0,0 @@
1 -<?xml version="1.0" encoding="utf-8"?>
2 -<!-- 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. -->
3 -
4 -
5 -<actions xmlns="http://wixtoolset.org/schemas/v4/wi/actions">
6 - <action name="InstallInitialize" sequence="1500" AdminExecuteSequence="yes" AdvtExecuteSequence="yes" InstallExecuteSequence="yes" />
7 - <action name="InstallExecute" condition="NOT Installed" sequence="6500" InstallExecuteSequence="yes" />
8 - <action name="InstallExecuteAgain" condition="NOT Installed" sequence="6550" InstallExecuteSequence="yes" />
9 - <action name="InstallFinalize" sequence="6600" AdminExecuteSequence="yes" AdvtExecuteSequence="yes" InstallExecuteSequence="yes" />
10 - <action name="InstallFiles" sequence="4000" AdminExecuteSequence="yes" InstallExecuteSequence="yes" />
11 - <action name="InstallAdminPackage" sequence="3900" AdminExecuteSequence="yes" />
12 - <action name="FileCost" sequence="900" AdminExecuteSequence="yes" AdminUISequence="yes" InstallExecuteSequence="yes" InstallUISequence="yes" />
13 - <action name="CostInitialize" sequence="800" AdminExecuteSequence="yes" AdminUISequence="yes" AdvtExecuteSequence="yes" InstallExecuteSequence="yes" InstallUISequence="yes" />
14 - <action name="CostFinalize" sequence="1000" AdminExecuteSequence="yes" AdminUISequence="yes" AdvtExecuteSequence="yes" InstallExecuteSequence="yes" InstallUISequence="yes" />
15 - <action name="InstallValidate" sequence="1400" AdminExecuteSequence="yes" AdvtExecuteSequence="yes" InstallExecuteSequence="yes" />
16 - <action name="ExecuteAction" sequence="1300" AdminUISequence="yes" InstallUISequence="yes" />
17 - <action name="CreateShortcuts" sequence="4500" AdvtExecuteSequence="yes" InstallExecuteSequence="yes" />
18 - <action name="MsiPublishAssemblies" sequence="6250" AdvtExecuteSequence="yes" InstallExecuteSequence="yes" />
19 - <action name="PublishComponents" sequence="6200" AdvtExecuteSequence="yes" InstallExecuteSequence="yes" />
20 - <action name="PublishFeatures" sequence="6300" AdvtExecuteSequence="yes" InstallExecuteSequence="yes" />
21 - <action name="PublishProduct" sequence="6400" AdvtExecuteSequence="yes" InstallExecuteSequence="yes" />
22 - <action name="RegisterClassInfo" sequence="4600" AdvtExecuteSequence="yes" InstallExecuteSequence="yes" />
23 - <action name="RegisterExtensionInfo" sequence="4700" AdvtExecuteSequence="yes" InstallExecuteSequence="yes" />
24 - <action name="RegisterMIMEInfo" sequence="4900" AdvtExecuteSequence="yes" InstallExecuteSequence="yes" />
25 - <action name="RegisterProgIdInfo" sequence="4800" AdvtExecuteSequence="yes" InstallExecuteSequence="yes" />
26 - <action name="AllocateRegistrySpace" condition="NOT Installed" sequence="1550" InstallExecuteSequence="yes" />
27 - <action name="AppSearch" sequence="50" InstallExecuteSequence="yes" InstallUISequence="yes" />
28 - <action name="BindImage" sequence="4300" InstallExecuteSequence="yes" />
29 - <action name="CCPSearch" condition="NOT Installed" sequence="500" InstallExecuteSequence="yes" InstallUISequence="yes" />
30 - <action name="CreateFolders" sequence="3700" InstallExecuteSequence="yes" />
31 - <action name="DeleteServices" condition="VersionNT" sequence="2000" InstallExecuteSequence="yes" />
32 - <action name="DuplicateFiles" sequence="4210" InstallExecuteSequence="yes" />
33 - <action name="FindRelatedProducts" sequence="25" InstallExecuteSequence="yes" InstallUISequence="yes" />
34 - <action name="InstallODBC" sequence="5400" InstallExecuteSequence="yes" />
35 - <action name="InstallServices" condition="VersionNT" sequence="5800" InstallExecuteSequence="yes" />
36 - <action name="MsiConfigureServices" condition="VersionNT>=600" sequence="5850" InstallExecuteSequence="yes" />
37 - <action name="IsolateComponents" sequence="950" InstallExecuteSequence="yes" InstallUISequence="yes" />
38 - <action name="LaunchConditions" sequence="100" AdminExecuteSequence="yes" AdminUISequence="yes" InstallExecuteSequence="yes" InstallUISequence="yes" />
39 - <action name="MigrateFeatureStates" sequence="1200" InstallExecuteSequence="yes" InstallUISequence="yes" />
40 - <action name="MoveFiles" sequence="3800" InstallExecuteSequence="yes" />
41 - <action name="PatchFiles" sequence="4090" AdminExecuteSequence="yes" InstallExecuteSequence="yes" />
42 - <action name="ProcessComponents" sequence="1600" InstallExecuteSequence="yes" />
43 - <action name="RegisterComPlus" sequence="5700" InstallExecuteSequence="yes" />
44 - <action name="RegisterFonts" sequence="5300" InstallExecuteSequence="yes" />
45 - <action name="RegisterProduct" sequence="6100" InstallExecuteSequence="yes" />
46 - <action name="RegisterTypeLibraries" sequence="5500" InstallExecuteSequence="yes" />
47 - <action name="RegisterUser" sequence="6000" InstallExecuteSequence="yes" />
48 - <action name="RemoveDuplicateFiles" sequence="3400" InstallExecuteSequence="yes" />
49 - <action name="RemoveEnvironmentStrings" sequence="3300" InstallExecuteSequence="yes" />
50 - <action name="RemoveFiles" sequence="3500" InstallExecuteSequence="yes" />
51 - <action name="RemoveFolders" sequence="3600" InstallExecuteSequence="yes" />
52 - <action name="RemoveIniValues" sequence="3100" InstallExecuteSequence="yes" />
53 - <action name="RemoveODBC" sequence="2400" InstallExecuteSequence="yes" />
54 - <action name="RemoveRegistryValues" sequence="2600" InstallExecuteSequence="yes" />
55 - <action name="RemoveShortcuts" sequence="3200" InstallExecuteSequence="yes" />
56 - <action name="RMCCPSearch" condition="NOT Installed" sequence="600" InstallExecuteSequence="yes" InstallUISequence="yes" />
57 - <action name="SelfRegModules" sequence="5600" InstallExecuteSequence="yes" />
58 - <action name="SelfUnregModules" sequence="2200" InstallExecuteSequence="yes" />
59 - <action name="SetODBCFolders" sequence="1100" InstallExecuteSequence="yes" />
60 - <action name="StartServices" condition="VersionNT" sequence="5900" InstallExecuteSequence="yes" />
61 - <action name="StopServices" condition="VersionNT" sequence="1900" InstallExecuteSequence="yes" />
62 - <action name="MsiUnpublishAssemblies" sequence="1750" InstallExecuteSequence="yes" />
63 - <action name="UnpublishComponents" sequence="1700" InstallExecuteSequence="yes" />
64 - <action name="UnpublishFeatures" sequence="1800" InstallExecuteSequence="yes" />
65 - <action name="UnregisterClassInfo" sequence="2700" InstallExecuteSequence="yes" />
66 - <action name="UnregisterComPlus" sequence="2100" InstallExecuteSequence="yes" />
67 - <action name="UnregisterExtensionInfo" sequence="2800" InstallExecuteSequence="yes" />
68 - <action name="UnregisterFonts" sequence="2500" InstallExecuteSequence="yes" />
69 - <action name="UnregisterMIMEInfo" sequence="3000" InstallExecuteSequence="yes" />
70 - <action name="UnregisterProgIdInfo" sequence="2900" InstallExecuteSequence="yes" />
71 - <action name="UnregisterTypeLibraries" sequence="2300" InstallExecuteSequence="yes" />
72 - <action name="ValidateProductID" sequence="700" InstallExecuteSequence="yes" InstallUISequence="yes" />
73 - <action name="WriteEnvironmentStrings" sequence="5200" InstallExecuteSequence="yes" />
74 - <action name="WriteIniValues" sequence="5100" InstallExecuteSequence="yes" />
75 - <action name="WriteRegistryValues" sequence="5000" InstallExecuteSequence="yes" />
76 -</actions>
src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs
+15 -16
@@ -13,7 +13,6 @@ namespace WixToolset.Core.WindowsInstaller
13 using System.Text.RegularExpressions;
14 using System.Xml.Linq;
15 using WixToolset.Core;
16 - using WixToolset.Core.WindowsInstaller.Rows;
16 using WixToolset.Data;
17 using WixToolset.Data.Tuples;
18 using WixToolset.Data.WindowsInstaller;
@@ -104,7 +103,7 @@ namespace WixToolset.Core.WindowsInstaller
103 {
104 if (null == output)
105 {
107 - throw new ArgumentNullException("output");
106 + throw new ArgumentNullException(nameof(output));
107 }
108
109 this.OutputType = output.Type;
@@ -1534,9 +1533,7 @@ namespace WixToolset.Core.WindowsInstaller
1533
1534 foreach (Wix.ISchemaElement element in component.Children)
1535 {
1537 - var file = element as Wix.File;
1538 -
1539 - if (null != file && Wix.YesNoType.yes == file.KeyPath)
1536 + if (element is Wix.File file && Wix.YesNoType.yes == file.KeyPath)
1537 {
1538 file.AddChild(typeLib);
1539 }
@@ -2511,10 +2508,10 @@ namespace WixToolset.Core.WindowsInstaller
2508
2509 if (null != table)
2510 {
2514 - var actionRows = new ArrayList();
2511 + var actionRows = new List<WixActionRow>();
2512 var needAbsoluteScheduling = this.SuppressRelativeActionSequencing;
2516 - var nonSequencedActionRows = new WixActionRowCollection();
2517 - var suppressedRelativeActionRows = new WixActionRowCollection();
2513 + var nonSequencedActionRows = new Dictionary<string, WixActionRow>();
2514 + var suppressedRelativeActionRows = new Dictionary<string, WixActionRow>();
2515
2516 // create a sorted array of actions in this table
2517 foreach (var row in table.Rows)
@@ -2538,7 +2535,7 @@ namespace WixToolset.Core.WindowsInstaller
2535
2536 for (var i = 0; i < actionRows.Count && !needAbsoluteScheduling; i++)
2537 {
2541 - var actionRow = (WixActionRow)actionRows[i];
2538 + var actionRow = actionRows[i];
2539 this.StandardActions.TryGetValue(actionRow.GetPrimaryKey(), out var standardActionRow);
2540
2541 // create actions for custom actions, dialogs, AppSearch when its moved, and standard actions with non-standard conditions
@@ -2550,13 +2547,13 @@ namespace WixToolset.Core.WindowsInstaller
2547 // find the previous action row if there is one
2548 if (0 <= i - 1)
2549 {
2553 - previousActionRow = (WixActionRow)actionRows[i - 1];
2550 + previousActionRow = actionRows[i - 1];
2551 }
2552
2553 // find the next action row if there is one
2554 if (actionRows.Count > i + 1)
2555 {
2559 - nextActionRow = (WixActionRow)actionRows[i + 1];
2556 + nextActionRow = actionRows[i + 1];
2557 }
2558
2559 // the logic for setting the before or after attribute for an action:
@@ -2594,7 +2591,7 @@ namespace WixToolset.Core.WindowsInstaller
2591 }
2592 else if (null != standardActionRow && actionRow.Condition != standardActionRow.Condition) // standard actions get their standard sequence numbers
2593 {
2597 - nonSequencedActionRows.Add(actionRow);
2594 + nonSequencedActionRows.Add(actionRow.GetPrimaryKey(), actionRow);
2595 }
2596 else if (0 < actionRow.Sequence)
2597 {
@@ -2603,25 +2600,27 @@ namespace WixToolset.Core.WindowsInstaller
2600 }
2601 else
2602 {
2606 - suppressedRelativeActionRows.Add(actionRow);
2603 + suppressedRelativeActionRows.Add(actionRow.GetPrimaryKey(), actionRow);
2604 }
2605 }
2606
2607 // create the actions now that we know if they must be absolutely or relatively scheduled
2611 - foreach (WixActionRow actionRow in actionRows)
2608 + foreach (var actionRow in actionRows)
2609 {
2610 + var key = actionRow.GetPrimaryKey();
2611 +
2612 if (needAbsoluteScheduling)
2613 {
2614 // remove any before/after information to ensure this is absolutely sequenced
2615 actionRow.Before = null;
2616 actionRow.After = null;
2617 }
2619 - else if (nonSequencedActionRows.Contains(actionRow.SequenceTable, actionRow.Action))
2618 + else if (nonSequencedActionRows.ContainsKey(key))
2619 {
2620 // clear the sequence attribute to ensure this action is scheduled without a sequence number (or before/after)
2621 actionRow.Sequence = 0;
2622 }
2624 - else if (suppressedRelativeActionRows.Contains(actionRow.SequenceTable, actionRow.Action))
2623 + else if (suppressedRelativeActionRows.ContainsKey(key))
2624 {
2625 // skip the suppressed relatively scheduled action rows
2626 continue;
src/WixToolset.Core.WindowsInstaller/Rows/WixActionRowCollection.cs deleted
-329
@@ -1,329 +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.Core.WindowsInstaller.Rows
4 -{
5 - using System;
6 - using System.Collections;
7 - using System.Diagnostics;
8 - using System.Globalization;
9 - using System.Xml;
10 - using WixToolset.Data.Tuples;
11 - using WixToolset.Data.WindowsInstaller.Rows;
12 -
13 - /// <summary>
14 - /// A collection of action rows sorted by their sequence table and action name.
15 - /// </summary>
16 - // TODO: Remove this
17 - internal sealed class WixActionRowCollection : ICollection
18 - {
19 - private readonly SortedList collection;
20 -
21 - /// <summary>
22 - /// Creates a new action table object.
23 - /// </summary>
24 - public WixActionRowCollection()
25 - {
26 - this.collection = new SortedList();
27 - }
28 -
29 - /// <summary>
30 - /// Gets the number of items in the collection.
31 - /// </summary>
32 - /// <value>Number of items in collection.</value>
33 - public int Count
34 - {
35 - get { return this.collection.Count; }
36 - }
37 -
38 - /// <summary>
39 - /// Gets if the collection has been synchronized.
40 - /// </summary>
41 - /// <value>True if the collection has been synchronized.</value>
42 - public bool IsSynchronized
43 - {
44 - get { return this.collection.IsSynchronized; }
45 - }
46 -
47 - /// <summary>
48 - /// Gets the object used to synchronize the collection.
49 - /// </summary>
50 - /// <value>Oject used the synchronize the collection.</value>
51 - public object SyncRoot
52 - {
53 - get { return this; }
54 - }
55 -
56 - /// <summary>
57 - /// Get an ActionRow by its sequence table and action name.
58 - /// </summary>
59 - /// <param name="sequenceTable">The sequence table of the ActionRow.</param>
60 - /// <param name="action">The action name of the ActionRow.</param>
61 - public WixActionRow this[SequenceTable sequenceTable, string action]
62 - {
63 - get { return (WixActionRow)this.collection[GetKey(sequenceTable, action)]; }
64 - }
65 -
66 - /// <summary>
67 - /// Add an ActionRow to the collection.
68 - /// </summary>
69 - /// <param name="actionRow">The ActionRow to add.</param>
70 - /// <param name="overwrite">true to overwrite an existing ActionRow; false otherwise.</param>
71 - public void Add(WixActionRow actionRow, bool overwrite)
72 - {
73 - string key = GetKey(actionRow.SequenceTable, actionRow.Action);
74 -
75 - if (overwrite)
76 - {
77 - this.collection[key] = actionRow;
78 - }
79 - else
80 - {
81 - this.collection.Add(key, actionRow);
82 - }
83 - }
84 -
85 - /// <summary>
86 - /// Add an ActionRow to the collection.
87 - /// </summary>
88 - /// <param name="actionRow">The ActionRow to add.</param>
89 - public void Add(WixActionRow actionRow)
90 - {
91 - this.Add(actionRow, false);
92 - }
93 -
94 - /// <summary>
95 - /// Determines if the collection contains an ActionRow with a specific sequence table and name.
96 - /// </summary>
97 - /// <param name="sequenceTable">The sequence table of the ActionRow.</param>
98 - /// <param name="action">The action name of the ActionRow.</param>
99 - /// <returns>true if the ActionRow was found; false otherwise.</returns>
100 - public bool Contains(SequenceTable sequenceTable, string action)
101 - {
102 - return this.collection.Contains(GetKey(sequenceTable, action));
103 - }
104 -
105 - /// <summary>
106 - /// Copies the collection into an array.
107 - /// </summary>
108 - /// <param name="array">Array to copy the collection into.</param>
109 - /// <param name="index">Index to start copying from.</param>
110 - public void CopyTo(System.Array array, int index)
111 - {
112 - this.collection.Values.CopyTo(array, index);
113 - }
114 -
115 - /// <summary>
116 - /// Gets the enumerator for the collection.
117 - /// </summary>
118 - /// <returns>The enumerator for the collection.</returns>
119 - public IEnumerator GetEnumerator()
120 - {
121 - return this.collection.Values.GetEnumerator();
122 - }
123 -
124 - /// <summary>
125 - /// Remove an ActionRow from the collection.
126 - /// </summary>
127 - /// <param name="sequenceTable">The sequence table of the ActionRow.</param>
128 - /// <param name="action">The action name of the ActionRow.</param>
129 - public void Remove(SequenceTable sequenceTable, string action)
130 - {
131 - this.collection.Remove(GetKey(sequenceTable, action));
132 - }
133 -
134 - /// <summary>
135 - /// Load an action table from an XmlReader.
136 - /// </summary>
137 - /// <param name="reader">Reader to get data from.</param>
138 - /// <returns>The ActionRowCollection represented by the xml.</returns>
139 - internal static WixActionRowCollection Load(XmlReader reader)
140 - {
141 - reader.MoveToContent();
142 -
143 - return Parse(reader);
144 - }
145 -
146 - /// <summary>
147 - /// Creates a new action table object and populates it from an Xml reader.
148 - /// </summary>
149 - /// <param name="reader">Reader to get data from.</param>
150 - /// <returns>The parsed ActionTable.</returns>
151 - private static WixActionRowCollection Parse(XmlReader reader)
152 - {
153 - if (!reader.LocalName.Equals("actions"))
154 - {
155 - throw new XmlException();
156 - }
157 -
158 - WixActionRowCollection actionRows = new WixActionRowCollection();
159 - bool empty = reader.IsEmptyElement;
160 -
161 - while (reader.MoveToNextAttribute())
162 - {
163 - }
164 -
165 - if (!empty)
166 - {
167 - bool done = false;
168 -
169 - // loop through all the fields in a row
170 - while (!done && reader.Read())
171 - {
172 - switch (reader.NodeType)
173 - {
174 - case XmlNodeType.Element:
175 - switch (reader.LocalName)
176 - {
177 - case "action":
178 - WixActionRow[] parsedActionRows = ParseActions(reader);
179 -
180 - foreach (WixActionRow actionRow in parsedActionRows)
181 - {
182 - actionRows.Add(actionRow);
183 - }
184 - break;
185 - default:
186 - throw new XmlException();
187 - }
188 - break;
189 - case XmlNodeType.EndElement:
190 - done = true;
191 - break;
192 - }
193 - }
194 -
195 - if (!done)
196 - {
197 - throw new XmlException();
198 - }
199 - }
200 -
201 - return actionRows;
202 - }
203 -
204 - /// <summary>
205 - /// Get the key for storing an ActionRow.
206 - /// </summary>
207 - /// <param name="sequenceTable">The sequence table of the ActionRow.</param>
208 - /// <param name="action">The action name of the ActionRow.</param>
209 - /// <returns>The string key.</returns>
210 - private static string GetKey(SequenceTable sequenceTable, string action)
211 - {
212 - return GetKey(sequenceTable.ToString(), action);
213 - }
214 -
215 - /// <summary>
216 - /// Get the key for storing an ActionRow.
217 - /// </summary>
218 - /// <param name="sequenceTable">The sequence table of the ActionRow.</param>
219 - /// <param name="action">The action name of the ActionRow.</param>
220 - /// <returns>The string key.</returns>
221 - private static string GetKey(string sequenceTable, string action)
222 - {
223 - return String.Concat(sequenceTable, '/', action);
224 - }
225 -
226 - /// <summary>
227 - /// Parses ActionRows from the Xml reader.
228 - /// </summary>
229 - /// <param name="reader">Xml reader that contains serialized ActionRows.</param>
230 - /// <returns>The parsed ActionRows.</returns>
231 - internal static WixActionRow[] ParseActions(XmlReader reader)
232 - {
233 - Debug.Assert("action" == reader.LocalName);
234 -
235 - string id = null;
236 - string condition = null;
237 - bool empty = reader.IsEmptyElement;
238 - int sequence = Int32.MinValue;
239 - int sequenceCount = 0;
240 - SequenceTable[] sequenceTables = new SequenceTable[Enum.GetValues(typeof(SequenceTable)).Length];
241 -
242 - while (reader.MoveToNextAttribute())
243 - {
244 - switch (reader.Name)
245 - {
246 - case "name":
247 - id = reader.Value;
248 - break;
249 - case "AdminExecuteSequence":
250 - if (reader.Value.Equals("yes"))
251 - {
252 - sequenceTables[sequenceCount] = SequenceTable.AdminExecuteSequence;
253 - ++sequenceCount;
254 - }
255 - break;
256 - case "AdminUISequence":
257 - if (reader.Value.Equals("yes"))
258 - {
259 - sequenceTables[sequenceCount] = SequenceTable.AdminUISequence;
260 - ++sequenceCount;
261 - }
262 - break;
263 - case "AdvtExecuteSequence":
264 - if (reader.Value.Equals("yes"))
265 - {
266 - sequenceTables[sequenceCount] = SequenceTable.AdvertiseExecuteSequence;
267 - ++sequenceCount;
268 - }
269 - break;
270 - case "condition":
271 - condition = reader.Value;
272 - break;
273 - case "InstallExecuteSequence":
274 - if (reader.Value.Equals("yes"))
275 - {
276 - sequenceTables[sequenceCount] = SequenceTable.InstallExecuteSequence;
277 - ++sequenceCount;
278 - }
279 - break;
280 - case "InstallUISequence":
281 - if (reader.Value.Equals("yes"))
282 - {
283 - sequenceTables[sequenceCount] = SequenceTable.InstallUISequence;
284 - ++sequenceCount;
285 - }
286 - break;
287 - case "sequence":
288 - sequence = Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture);
289 - break;
290 - }
291 - }
292 -
293 - if (null == id)
294 - {
295 - throw new XmlException();
296 - }
297 -
298 - if (Int32.MinValue == sequence)
299 - {
300 - throw new XmlException();
301 - }
302 - else if (1 > sequence)
303 - {
304 - throw new XmlException();
305 - }
306 -
307 - if (0 == sequenceCount)
308 - {
309 - throw new XmlException();
310 - }
311 -
312 - if (!empty && reader.Read() && XmlNodeType.EndElement != reader.MoveToContent())
313 - {
314 - throw new XmlException();
315 - }
316 -
317 - // create the actions
318 - WixActionRow[] actionRows = new WixActionRow[sequenceCount];
319 - for (var i = 0; i < sequenceCount; i++)
320 - {
321 - //WixActionRow actionRow = new WixActionRow(sequenceTables[i], id, condition, sequence);
322 - //actionRows[i] = actionRow;
323 - throw new NotImplementedException();
324 - }
325 -
326 - return actionRows;
327 - }
328 - }
329 -}
src/WixToolset.Core.WindowsInstaller/WindowsInstallerStandardInternal.cs
+2 -28
@@ -2,10 +2,8 @@
2
3 namespace WixToolset.Core.WindowsInstaller
4 {
5 - using System;
5 using System.Reflection;
6 using System.Xml;
8 - using WixToolset.Core.WindowsInstaller.Rows;
7 using WixToolset.Data.WindowsInstaller;
8
9 /// <summary>
@@ -16,9 +14,6 @@ namespace WixToolset.Core.WindowsInstaller
14 private static readonly object lockObject = new object();
15
16 private static TableDefinitionCollection tableDefinitions;
19 -#if REVISIT_FOR_PATCHING
20 - private static WixActionRowCollection standardActions;
21 -#endif
17
18 /// <summary>
19 /// Gets the table definitions stored in this assembly.
@@ -26,6 +21,8 @@ namespace WixToolset.Core.WindowsInstaller
21 /// <returns>Table definition collection for tables stored in this assembly.</returns>
22 public static TableDefinitionCollection GetTableDefinitions()
23 {
24 + // TODO: make the data static data structures instead of parsing an XML file and consider
25 + // moving it all to WixToolset.Data.WindowsInstallerStandard class.
26 lock (lockObject)
27 {
28 if (null == WindowsInstallerStandardInternal.tableDefinitions)
@@ -39,28 +36,5 @@ namespace WixToolset.Core.WindowsInstaller
36
37 return WindowsInstallerStandardInternal.tableDefinitions;
38 }
42 -
43 - /// <summary>
44 - /// Gets the standard actions stored in this assembly.
45 - /// </summary>
46 - /// <returns>Collection of standard actions in this assembly.</returns>
47 - public static WixActionRowCollection GetStandardActionRows()
48 - {
49 -#if REVISIT_FOR_PATCHING
50 - lock (lockObject)
51 - {
52 - if (null == WindowsInstallerStandardInternal.standardActions)
53 - {
54 - using (XmlReader reader = XmlReader.Create(Assembly.GetExecutingAssembly().GetManifestResourceStream("WixToolset.Core.WindowsInstaller.Data.actions.xml")))
55 - {
56 - WindowsInstallerStandardInternal.standardActions = WixActionRowCollection.Load(reader);
57 - }
58 - }
59 - }
60 -
61 - return WindowsInstallerStandardInternal.standardActions;
62 -#endif
63 - throw new NotImplementedException();
64 - }
39 }
40 }
src/WixToolset.Core.WindowsInstaller/WixToolset.Core.WindowsInstaller.csproj
-1
@@ -11,7 +11,6 @@
11 </PropertyGroup>
12
13 <ItemGroup>
14 - <EmbeddedResource Include="Data\actions.xml" />
14 <EmbeddedResource Include="Data\tables.xml" />
15 </ItemGroup>
16