@joebigelow / wix-1 / commits / a85f2e99

Support loading WindowsInstallerData and Intermediate from WixOutput.

Bob Arnson committed Feb 10, 2020 at 14:10 UTC a85f2e992a301abe5d2c0d58f07e7bc9692ff6e3
2 files changed +43 -5
src/WixToolset.Data/Intermediate.cs
+25
@@ -107,6 +107,31 @@ namespace WixToolset.Data
107 }
108 }
109
110 + /// <summary>
111 + /// Loads an intermediate from a WixOutput object.
112 + /// </summary>
113 + /// <param name="wixOutput">WixOutput object.</param>
114 + /// <param name="creator">ITupleDefinitionCreator to use when reconstituting the intermediate.</param>
115 + /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
116 + /// <returns>Returns the loaded intermediate.</returns>
117 + public static Intermediate Load(WixOutput wixOutput, bool suppressVersionCheck = false)
118 + {
119 + var creator = new SimpleTupleDefinitionCreator();
120 + return Intermediate.LoadIntermediate(wixOutput, creator, suppressVersionCheck);
121 + }
122 +
123 + /// <summary>
124 + /// Loads an intermediate from a WixOutput object.
125 + /// </summary>
126 + /// <param name="wixOutput">WixOutput object.</param>
127 + /// <param name="creator">ITupleDefinitionCreator to use when reconstituting the intermediate.</param>
128 + /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
129 + /// <returns>Returns the loaded intermediate.</returns>
130 + public static Intermediate Load(WixOutput wixOutput, ITupleDefinitionCreator creator, bool suppressVersionCheck = false)
131 + {
132 + return Intermediate.LoadIntermediate(wixOutput, creator, suppressVersionCheck);
133 + }
134 +
135 /// <summary>
136 /// Loads several intermediates from paths on disk using the same definitions.
137 /// </summary>
src/WixToolset.Data/WindowsInstaller/WindowsInstallerData.cs
+18 -5
@@ -102,11 +102,24 @@ namespace WixToolset.Data.WindowsInstaller
102 /// <param name="path">Path to output file saved on disk.</param>
103 /// <param name="suppressVersionCheck">Suppresses wix.dll version mismatch check.</param>
104 /// <returns>Output object.</returns>
105 - public static WindowsInstallerData Load(string path, bool suppressVersionCheck)
105 + public static WindowsInstallerData Load(string path, bool suppressVersionCheck = false)
106 {
107 - using (var wixout = WixOutput.Read(path))
108 - using (var stream = wixout.GetDataStream(WixOutputStreamName))
109 - using (var reader = XmlReader.Create(stream, null, wixout.Uri.AbsoluteUri))
107 + using (var wixOutput = WixOutput.Read(path))
108 + {
109 + return WindowsInstallerData.Load(wixOutput, suppressVersionCheck);
110 + }
111 + }
112 +
113 + /// <summary>
114 + /// Loads an output from a WixOutput object.
115 + /// </summary>
116 + /// <param name="wixOutput">WixOutput object.</param>
117 + /// <param name="suppressVersionCheck">Suppresses wix.dll version mismatch check.</param>
118 + /// <returns>Output object.</returns>
119 + public static WindowsInstallerData Load(WixOutput wixOutput, bool suppressVersionCheck = false)
120 + {
121 + using (var stream = wixOutput.GetDataStream(WixOutputStreamName))
122 + using (var reader = XmlReader.Create(stream, null, wixOutput.Uri.AbsoluteUri))
123 {
124 try
125 {
@@ -115,7 +128,7 @@ namespace WixToolset.Data.WindowsInstaller
128 }
129 catch (XmlException xe)
130 {
118 - throw new WixCorruptFileException(path, "wixout", xe);
131 + throw new WixCorruptFileException(wixOutput.Uri.AbsoluteUri, "wixout", xe);
132 }
133 }
134 }