| 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.Bind |
| 4 | { |
| 5 | using System; |
| 6 | using System.Collections.Generic; |
| 7 | using WixToolset.Data.Symbols; |
| 8 | using WixToolset.Data.WindowsInstaller; |
| 9 | |
| 10 | /// <summary> |
| 11 | /// Add back possibly suppressed sequence tables since all sequence tables must be present |
| 12 | /// for the merge process to work. We'll drop the suppressed sequence tables again as |
| 13 | /// necessary. |
| 14 | /// </summary> |
| 15 | internal class AddBackSuppressedSequenceTablesCommand |
| 16 | { |
| 17 | public AddBackSuppressedSequenceTablesCommand(WindowsInstallerData output, TableDefinitionCollection tableDefinitions) |
| 18 | { |
| 19 | this.Output = output; |
| 20 | this.TableDefinitions = tableDefinitions; |
| 21 | } |
| 22 | |
| 23 | private WindowsInstallerData Output { get; } |
| 24 | |
| 25 | private TableDefinitionCollection TableDefinitions { get; } |
| 26 | |
| 27 | public IEnumerable<string> SuppressedTableNames { get; private set; } |
| 28 | |
| 29 | public IEnumerable<string> Execute() |
| 30 | { |
| 31 | var suppressedTableNames = new HashSet<string>(); |
| 32 | |
| 33 | foreach (SequenceTable sequence in Enum.GetValues(typeof(SequenceTable))) |
| 34 | { |
| 35 | var sequenceTableName = sequence.WindowsInstallerTableName(); |
| 36 | var sequenceTable = this.Output.Tables[sequenceTableName]; |
| 37 | |
| 38 | if (null == sequenceTable) |
| 39 | { |
| 40 | sequenceTable = this.Output.EnsureTable(this.TableDefinitions[sequenceTableName]); |
| 41 | } |
| 42 | |
| 43 | if (0 == sequenceTable.Rows.Count) |
| 44 | { |
| 45 | suppressedTableNames.Add(sequenceTableName); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | return this.SuppressedTableNames = suppressedTableNames; |
| 50 | } |
| 51 | } |
| 52 | } |