diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/WixToolset.Data/WindowsInstaller/SequenceTableExtensions.cs | 17 | ||||
| -rw-r--r-- | src/WixToolset.Data/WindowsInstaller/Table.cs | 42 |
2 files changed, 38 insertions, 21 deletions
diff --git a/src/WixToolset.Data/WindowsInstaller/SequenceTableExtensions.cs b/src/WixToolset.Data/WindowsInstaller/SequenceTableExtensions.cs new file mode 100644 index 00000000..099d722a --- /dev/null +++ b/src/WixToolset.Data/WindowsInstaller/SequenceTableExtensions.cs | |||
| @@ -0,0 +1,17 @@ | |||
| 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.WindowsInstaller | ||
| 4 | { | ||
| 5 | using WixToolset.Data.Tuples; | ||
| 6 | |||
| 7 | /// <summary> | ||
| 8 | /// Enhancements to the SequenceTable enum. | ||
| 9 | /// </summary> | ||
| 10 | public static class SequenceTableExtensions | ||
| 11 | { | ||
| 12 | /// <summary> | ||
| 13 | /// Gets the SequenceTable enum as the Windows Installer table name. | ||
| 14 | /// </summary> | ||
| 15 | public static string WindowsInstallerTableName(this SequenceTable sequence) => (sequence == SequenceTable.AdvertiseExecuteSequence) ? "AdvtExecuteSequence" : sequence.ToString(); | ||
| 16 | } | ||
| 17 | } | ||
diff --git a/src/WixToolset.Data/WindowsInstaller/Table.cs b/src/WixToolset.Data/WindowsInstaller/Table.cs index ca6fe3ba..714be20f 100644 --- a/src/WixToolset.Data/WindowsInstaller/Table.cs +++ b/src/WixToolset.Data/WindowsInstaller/Table.cs | |||
| @@ -60,6 +60,27 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | /// <summary> | 62 | /// <summary> |
| 63 | /// Validates the rows of this OutputTable and throws if it collides on | ||
| 64 | /// primary keys. | ||
| 65 | /// </summary> | ||
| 66 | public void ValidateRows() | ||
| 67 | { | ||
| 68 | var primaryKeys = new Dictionary<string, SourceLineNumber>(); | ||
| 69 | |||
| 70 | foreach (var row in this.Rows) | ||
| 71 | { | ||
| 72 | var primaryKey = row.GetPrimaryKey(); | ||
| 73 | |||
| 74 | if (primaryKeys.TryGetValue(primaryKey, out var collisionSourceLineNumber)) | ||
| 75 | { | ||
| 76 | throw new WixException(ErrorMessages.DuplicatePrimaryKey(collisionSourceLineNumber, primaryKey, this.Definition.Name)); | ||
| 77 | } | ||
| 78 | |||
| 79 | primaryKeys.Add(primaryKey, row.SourceLineNumbers); | ||
| 80 | } | ||
| 81 | } | ||
| 82 | |||
| 83 | /// <summary> | ||
| 63 | /// Parse a table from the xml. | 84 | /// Parse a table from the xml. |
| 64 | /// </summary> | 85 | /// </summary> |
| 65 | /// <param name="reader">XmlReader where the intermediate is persisted.</param> | 86 | /// <param name="reader">XmlReader where the intermediate is persisted.</param> |
| @@ -165,26 +186,5 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 165 | 186 | ||
| 166 | writer.WriteEndElement(); | 187 | writer.WriteEndElement(); |
| 167 | } | 188 | } |
| 168 | |||
| 169 | /// <summary> | ||
| 170 | /// Validates the rows of this OutputTable and throws if it collides on | ||
| 171 | /// primary keys. | ||
| 172 | /// </summary> | ||
| 173 | public void ValidateRows() | ||
| 174 | { | ||
| 175 | var primaryKeys = new Dictionary<string, SourceLineNumber>(); | ||
| 176 | |||
| 177 | foreach (var row in this.Rows) | ||
| 178 | { | ||
| 179 | var primaryKey = row.GetPrimaryKey(); | ||
| 180 | |||
| 181 | if (primaryKeys.TryGetValue(primaryKey, out var collisionSourceLineNumber)) | ||
| 182 | { | ||
| 183 | throw new WixException(ErrorMessages.DuplicatePrimaryKey(collisionSourceLineNumber, primaryKey, this.Definition.Name)); | ||
| 184 | } | ||
| 185 | |||
| 186 | primaryKeys.Add(primaryKey, row.SourceLineNumbers); | ||
| 187 | } | ||
| 188 | } | ||
| 189 | } | 189 | } |
| 190 | } | 190 | } |
