aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data/WindowsInstaller/WindowsInstallerData.cs
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-05-29 11:44:46 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-05-29 11:46:53 +1000
commit311dbab658184e603953791a075c776456226b95 (patch)
tree7767f664492a11d1721b37200a0a45077222d3c6 /src/WixToolset.Data/WindowsInstaller/WindowsInstallerData.cs
parente25b29f5ded38e281f3a686bc5ce7cbe1d872d3b (diff)
downloadwix-311dbab658184e603953791a075c776456226b95.tar.gz
wix-311dbab658184e603953791a075c776456226b95.tar.bz2
wix-311dbab658184e603953791a075c776456226b95.zip
Add overloads to WindowsInstallerData.Load for table definitions.
Diffstat (limited to 'src/WixToolset.Data/WindowsInstaller/WindowsInstallerData.cs')
-rw-r--r--src/WixToolset.Data/WindowsInstaller/WindowsInstallerData.cs43
1 files changed, 35 insertions, 8 deletions
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
@@ -113,9 +113,22 @@ namespace WixToolset.Data.WindowsInstaller
113 /// <returns>Output object.</returns> 113 /// <returns>Output object.</returns>
114 public static WindowsInstallerData Load(string path, bool suppressVersionCheck = false) 114 public static WindowsInstallerData Load(string path, bool suppressVersionCheck = false)
115 { 115 {
116 var tableDefinitions = new TableDefinitionCollection(WindowsInstallerTableDefinitions.All);
117 return WindowsInstallerData.Load(path, tableDefinitions, suppressVersionCheck);
118 }
119
120 /// <summary>
121 /// Loads an output from a path on disk.
122 /// </summary>
123 /// <param name="path">Path to output file saved on disk.</param>
124 /// <param name="tableDefinitions">Table definitions to use for creating strongly-typed rows.</param>
125 /// <param name="suppressVersionCheck">Suppresses wix.dll version mismatch check.</param>
126 /// <returns>Output object.</returns>
127 public static WindowsInstallerData Load(string path, TableDefinitionCollection tableDefinitions, bool suppressVersionCheck = false)
128 {
116 using (var wixOutput = WixOutput.Read(path)) 129 using (var wixOutput = WixOutput.Read(path))
117 { 130 {
118 return WindowsInstallerData.Load(wixOutput, suppressVersionCheck); 131 return WindowsInstallerData.Load(wixOutput, tableDefinitions, suppressVersionCheck);
119 } 132 }
120 } 133 }
121 134
@@ -127,13 +140,26 @@ namespace WixToolset.Data.WindowsInstaller
127 /// <returns>Output object.</returns> 140 /// <returns>Output object.</returns>
128 public static WindowsInstallerData Load(WixOutput wixOutput, bool suppressVersionCheck = false) 141 public static WindowsInstallerData Load(WixOutput wixOutput, bool suppressVersionCheck = false)
129 { 142 {
143 var tableDefinitions = new TableDefinitionCollection(WindowsInstallerTableDefinitions.All);
144 return WindowsInstallerData.Load(wixOutput, tableDefinitions, suppressVersionCheck);
145 }
146
147 /// <summary>
148 /// Loads an output from a WixOutput object.
149 /// </summary>
150 /// <param name="wixOutput">WixOutput object.</param>
151 /// <param name="tableDefinitions">Table definitions to use for creating strongly-typed rows.</param>
152 /// <param name="suppressVersionCheck">Suppresses wix.dll version mismatch check.</param>
153 /// <returns>Output object.</returns>
154 public static WindowsInstallerData Load(WixOutput wixOutput, TableDefinitionCollection tableDefinitions, bool suppressVersionCheck = false)
155 {
130 using (var stream = wixOutput.GetDataStream(WixOutputStreamName)) 156 using (var stream = wixOutput.GetDataStream(WixOutputStreamName))
131 using (var reader = XmlReader.Create(stream, null, wixOutput.Uri.AbsoluteUri)) 157 using (var reader = XmlReader.Create(stream, null, wixOutput.Uri.AbsoluteUri))
132 { 158 {
133 try 159 try
134 { 160 {
135 reader.MoveToContent(); 161 reader.MoveToContent();
136 return WindowsInstallerData.Read(reader, suppressVersionCheck); 162 return WindowsInstallerData.Read(reader, tableDefinitions, suppressVersionCheck);
137 } 163 }
138 catch (XmlException xe) 164 catch (XmlException xe)
139 { 165 {
@@ -146,9 +172,10 @@ namespace WixToolset.Data.WindowsInstaller
146 /// Processes an XmlReader and builds up the output object. 172 /// Processes an XmlReader and builds up the output object.
147 /// </summary> 173 /// </summary>
148 /// <param name="reader">Reader to get data from.</param> 174 /// <param name="reader">Reader to get data from.</param>
175 /// <param name="tableDefinitions">Table definitions to use for creating strongly-typed rows.</param>
149 /// <param name="suppressVersionCheck">Suppresses wix.dll version mismatch check.</param> 176 /// <param name="suppressVersionCheck">Suppresses wix.dll version mismatch check.</param>
150 /// <returns>The Output represented by the Xml.</returns> 177 /// <returns>The Output represented by the Xml.</returns>
151 internal static WindowsInstallerData Read(XmlReader reader, bool suppressVersionCheck) 178 internal static WindowsInstallerData Read(XmlReader reader, TableDefinitionCollection tableDefinitions, bool suppressVersionCheck)
152 { 179 {
153 if (!reader.LocalName.Equals(WindowsInstallerData.XmlElementName)) 180 if (!reader.LocalName.Equals(WindowsInstallerData.XmlElementName))
154 { 181 {
@@ -203,7 +230,7 @@ namespace WixToolset.Data.WindowsInstaller
203 } 230 }
204 231
205 // loop through the rest of the xml building up the Output object 232 // loop through the rest of the xml building up the Output object
206 TableDefinitionCollection tableDefinitions = null; 233 TableDefinitionCollection xmlTableDefinitions = null;
207 var tables = new List<Table>(); 234 var tables = new List<Table>();
208 if (!empty) 235 if (!empty)
209 { 236 {
@@ -218,17 +245,17 @@ namespace WixToolset.Data.WindowsInstaller
218 switch (reader.LocalName) 245 switch (reader.LocalName)
219 { 246 {
220 case "subStorage": 247 case "subStorage":
221 output.SubStorages.Add(SubStorage.Read(reader)); 248 output.SubStorages.Add(SubStorage.Read(reader, tableDefinitions));
222 break; 249 break;
223 case "table": 250 case "table":
224 if (null == tableDefinitions) 251 if (null == xmlTableDefinitions)
225 { 252 {
226 throw new XmlException(); 253 throw new XmlException();
227 } 254 }
228 tables.Add(Table.Read(reader, tableDefinitions)); 255 tables.Add(Table.Read(reader, xmlTableDefinitions));
229 break; 256 break;
230 case "tableDefinitions": 257 case "tableDefinitions":
231 tableDefinitions = TableDefinitionCollection.Read(reader); 258 xmlTableDefinitions = TableDefinitionCollection.Read(reader, tableDefinitions);
232 break; 259 break;
233 default: 260 default:
234 throw new XmlException(); 261 throw new XmlException();