From 58791d3dbffce2a96280e08fc2d36ab69571d02c Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 4 Jun 2020 10:18:50 -0700 Subject: Add SequenceTable.WindowsInstallerTableName() and other minor clean up --- .../WindowsInstaller/SequenceTableExtensions.cs | 17 +++++++++ src/WixToolset.Data/WindowsInstaller/Table.cs | 42 +++++++++++----------- 2 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 src/WixToolset.Data/WindowsInstaller/SequenceTableExtensions.cs (limited to 'src/WixToolset.Data') 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 @@ +// 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. + +namespace WixToolset.Data.WindowsInstaller +{ + using WixToolset.Data.Tuples; + + /// + /// Enhancements to the SequenceTable enum. + /// + public static class SequenceTableExtensions + { + /// + /// Gets the SequenceTable enum as the Windows Installer table name. + /// + public static string WindowsInstallerTableName(this SequenceTable sequence) => (sequence == SequenceTable.AdvertiseExecuteSequence) ? "AdvtExecuteSequence" : sequence.ToString(); + } +} 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 @@ -59,6 +59,27 @@ namespace WixToolset.Data.WindowsInstaller return row; } + /// + /// Validates the rows of this OutputTable and throws if it collides on + /// primary keys. + /// + public void ValidateRows() + { + var primaryKeys = new Dictionary(); + + foreach (var row in this.Rows) + { + var primaryKey = row.GetPrimaryKey(); + + if (primaryKeys.TryGetValue(primaryKey, out var collisionSourceLineNumber)) + { + throw new WixException(ErrorMessages.DuplicatePrimaryKey(collisionSourceLineNumber, primaryKey, this.Definition.Name)); + } + + primaryKeys.Add(primaryKey, row.SourceLineNumbers); + } + } + /// /// Parse a table from the xml. /// @@ -165,26 +186,5 @@ namespace WixToolset.Data.WindowsInstaller writer.WriteEndElement(); } - - /// - /// Validates the rows of this OutputTable and throws if it collides on - /// primary keys. - /// - public void ValidateRows() - { - var primaryKeys = new Dictionary(); - - foreach (var row in this.Rows) - { - var primaryKey = row.GetPrimaryKey(); - - if (primaryKeys.TryGetValue(primaryKey, out var collisionSourceLineNumber)) - { - throw new WixException(ErrorMessages.DuplicatePrimaryKey(collisionSourceLineNumber, primaryKey, this.Definition.Name)); - } - - primaryKeys.Add(primaryKey, row.SourceLineNumbers); - } - } } } -- cgit v1.2.3-55-g6feb