From 311dbab658184e603953791a075c776456226b95 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 29 May 2020 11:44:46 +1000 Subject: Add overloads to WindowsInstallerData.Load for table definitions. --- .../WindowsInstaller/WindowsInstallerData.cs | 43 ++++++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) (limited to 'src/WixToolset.Data/WindowsInstaller/WindowsInstallerData.cs') diff --git a/src/WixToolset.Data/WindowsInstaller/WindowsInstallerData.cs b/src/WixToolset.Data/WindowsInstaller/WindowsInstallerData.cs index e30be598..67a074c6 100644 --- a/src/WixToolset.Data/WindowsInstaller/WindowsInstallerData.cs +++ b/src/WixToolset.Data/WindowsInstaller/WindowsInstallerData.cs @@ -112,10 +112,23 @@ namespace WixToolset.Data.WindowsInstaller /// Suppresses wix.dll version mismatch check. /// Output object. public static WindowsInstallerData Load(string path, bool suppressVersionCheck = false) + { + var tableDefinitions = new TableDefinitionCollection(WindowsInstallerTableDefinitions.All); + return WindowsInstallerData.Load(path, tableDefinitions, suppressVersionCheck); + } + + /// + /// Loads an output from a path on disk. + /// + /// Path to output file saved on disk. + /// Table definitions to use for creating strongly-typed rows. + /// Suppresses wix.dll version mismatch check. + /// Output object. + public static WindowsInstallerData Load(string path, TableDefinitionCollection tableDefinitions, bool suppressVersionCheck = false) { using (var wixOutput = WixOutput.Read(path)) { - return WindowsInstallerData.Load(wixOutput, suppressVersionCheck); + return WindowsInstallerData.Load(wixOutput, tableDefinitions, suppressVersionCheck); } } @@ -126,6 +139,19 @@ namespace WixToolset.Data.WindowsInstaller /// Suppresses wix.dll version mismatch check. /// Output object. public static WindowsInstallerData Load(WixOutput wixOutput, bool suppressVersionCheck = false) + { + var tableDefinitions = new TableDefinitionCollection(WindowsInstallerTableDefinitions.All); + return WindowsInstallerData.Load(wixOutput, tableDefinitions, suppressVersionCheck); + } + + /// + /// Loads an output from a WixOutput object. + /// + /// WixOutput object. + /// Table definitions to use for creating strongly-typed rows. + /// Suppresses wix.dll version mismatch check. + /// Output object. + public static WindowsInstallerData Load(WixOutput wixOutput, TableDefinitionCollection tableDefinitions, bool suppressVersionCheck = false) { using (var stream = wixOutput.GetDataStream(WixOutputStreamName)) using (var reader = XmlReader.Create(stream, null, wixOutput.Uri.AbsoluteUri)) @@ -133,7 +159,7 @@ namespace WixToolset.Data.WindowsInstaller try { reader.MoveToContent(); - return WindowsInstallerData.Read(reader, suppressVersionCheck); + return WindowsInstallerData.Read(reader, tableDefinitions, suppressVersionCheck); } catch (XmlException xe) { @@ -146,9 +172,10 @@ namespace WixToolset.Data.WindowsInstaller /// Processes an XmlReader and builds up the output object. /// /// Reader to get data from. + /// Table definitions to use for creating strongly-typed rows. /// Suppresses wix.dll version mismatch check. /// The Output represented by the Xml. - internal static WindowsInstallerData Read(XmlReader reader, bool suppressVersionCheck) + internal static WindowsInstallerData Read(XmlReader reader, TableDefinitionCollection tableDefinitions, bool suppressVersionCheck) { if (!reader.LocalName.Equals(WindowsInstallerData.XmlElementName)) { @@ -203,7 +230,7 @@ namespace WixToolset.Data.WindowsInstaller } // loop through the rest of the xml building up the Output object - TableDefinitionCollection tableDefinitions = null; + TableDefinitionCollection xmlTableDefinitions = null; var tables = new List(); if (!empty) { @@ -218,17 +245,17 @@ namespace WixToolset.Data.WindowsInstaller switch (reader.LocalName) { case "subStorage": - output.SubStorages.Add(SubStorage.Read(reader)); + output.SubStorages.Add(SubStorage.Read(reader, tableDefinitions)); break; case "table": - if (null == tableDefinitions) + if (null == xmlTableDefinitions) { throw new XmlException(); } - tables.Add(Table.Read(reader, tableDefinitions)); + tables.Add(Table.Read(reader, xmlTableDefinitions)); break; case "tableDefinitions": - tableDefinitions = TableDefinitionCollection.Read(reader); + xmlTableDefinitions = TableDefinitionCollection.Read(reader, tableDefinitions); break; default: throw new XmlException(); -- cgit v1.2.3-55-g6feb