diff options
author | Rob Mensching <rob@firegiant.com> | 2017-12-19 12:25:40 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2017-12-19 12:25:40 -0800 |
commit | 155a6e96346e0cb3d9ab6f5372fa29b46ebaee89 (patch) | |
tree | 59d1f151bfde8068b6014b05b5c8cfea3402c974 /src/WixToolset.Core.WindowsInstaller/Validator.cs | |
parent | 6f1665ed759b31bd095f186f9239232c653597cd (diff) | |
download | wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.tar.gz wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.tar.bz2 wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.zip |
Integrate simplified message handling
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Validator.cs')
-rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Validator.cs | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Validator.cs b/src/WixToolset.Core.WindowsInstaller/Validator.cs index eb17d8af..d553cc71 100644 --- a/src/WixToolset.Core.WindowsInstaller/Validator.cs +++ b/src/WixToolset.Core.WindowsInstaller/Validator.cs | |||
@@ -22,7 +22,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
22 | /// <summary> | 22 | /// <summary> |
23 | /// Runs internal consistency evaluators (ICEs) from cub files against a database. | 23 | /// Runs internal consistency evaluators (ICEs) from cub files against a database. |
24 | /// </summary> | 24 | /// </summary> |
25 | public sealed class Validator : IMessageHandler | 25 | public sealed class Validator |
26 | { | 26 | { |
27 | private string actionName; | 27 | private string actionName; |
28 | private StringCollection cubeFiles; | 28 | private StringCollection cubeFiles; |
@@ -30,15 +30,17 @@ namespace WixToolset.Core.WindowsInstaller | |||
30 | private Output output; | 30 | private Output output; |
31 | private InstallUIHandler validationUIHandler; | 31 | private InstallUIHandler validationUIHandler; |
32 | private bool validationSessionComplete; | 32 | private bool validationSessionComplete; |
33 | private readonly IMessaging messaging; | ||
33 | 34 | ||
34 | /// <summary> | 35 | /// <summary> |
35 | /// Instantiate a new Validator. | 36 | /// Instantiate a new Validator. |
36 | /// </summary> | 37 | /// </summary> |
37 | public Validator() | 38 | public Validator(IMessaging messaging) |
38 | { | 39 | { |
39 | this.cubeFiles = new StringCollection(); | 40 | this.cubeFiles = new StringCollection(); |
40 | this.extension = new ValidatorExtension(); | 41 | this.extension = new ValidatorExtension(messaging); |
41 | this.validationUIHandler = new InstallUIHandler(this.ValidationUIHandler); | 42 | this.validationUIHandler = new InstallUIHandler(this.ValidationUIHandler); |
43 | this.messaging = messaging; | ||
42 | } | 44 | } |
43 | 45 | ||
44 | /// <summary> | 46 | /// <summary> |
@@ -127,7 +129,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
127 | { | 129 | { |
128 | if (!mutex.WaitOne(0, false)) | 130 | if (!mutex.WaitOne(0, false)) |
129 | { | 131 | { |
130 | this.OnMessage(WixVerboses.ValidationSerialized()); | 132 | this.messaging.Write(VerboseMessages.ValidationSerialized()); |
131 | mutex.WaitOne(); | 133 | mutex.WaitOne(); |
132 | } | 134 | } |
133 | 135 | ||
@@ -176,7 +178,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
176 | { | 178 | { |
177 | if (0x6E == e.NativeErrorCode) // ERROR_OPEN_FAILED | 179 | if (0x6E == e.NativeErrorCode) // ERROR_OPEN_FAILED |
178 | { | 180 | { |
179 | throw new WixException(WixErrors.CubeFileNotFound(cubeFile)); | 181 | throw new WixException(ErrorMessages.CubeFileNotFound(cubeFile)); |
180 | } | 182 | } |
181 | 183 | ||
182 | throw; | 184 | throw; |
@@ -248,7 +250,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
248 | } | 250 | } |
249 | catch (Win32Exception e) | 251 | catch (Win32Exception e) |
250 | { | 252 | { |
251 | if (!Messaging.Instance.EncounteredError) | 253 | if (!this.messaging.EncounteredError) |
252 | { | 254 | { |
253 | throw e; | 255 | throw e; |
254 | } | 256 | } |
@@ -270,7 +272,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
270 | catch (Win32Exception e) | 272 | catch (Win32Exception e) |
271 | { | 273 | { |
272 | // avoid displaying errors twice since one may have already occurred in the UI handler | 274 | // avoid displaying errors twice since one may have already occurred in the UI handler |
273 | if (!Messaging.Instance.EncounteredError) | 275 | if (!this.messaging.EncounteredError) |
274 | { | 276 | { |
275 | if (0x6E == e.NativeErrorCode) // ERROR_OPEN_FAILED | 277 | if (0x6E == e.NativeErrorCode) // ERROR_OPEN_FAILED |
276 | { | 278 | { |
@@ -278,23 +280,23 @@ namespace WixToolset.Core.WindowsInstaller | |||
278 | // this would be the temporary copy and there would be | 280 | // this would be the temporary copy and there would be |
279 | // no final output since the error occured; during smoke | 281 | // no final output since the error occured; during smoke |
280 | // they should know the path passed into smoke | 282 | // they should know the path passed into smoke |
281 | this.OnMessage(WixErrors.ValidationFailedToOpenDatabase()); | 283 | this.messaging.Write(ErrorMessages.ValidationFailedToOpenDatabase()); |
282 | } | 284 | } |
283 | else if (0x64D == e.NativeErrorCode) | 285 | else if (0x64D == e.NativeErrorCode) |
284 | { | 286 | { |
285 | this.OnMessage(WixErrors.ValidationFailedDueToLowMsiEngine()); | 287 | this.messaging.Write(ErrorMessages.ValidationFailedDueToLowMsiEngine()); |
286 | } | 288 | } |
287 | else if (0x654 == e.NativeErrorCode) | 289 | else if (0x654 == e.NativeErrorCode) |
288 | { | 290 | { |
289 | this.OnMessage(WixErrors.ValidationFailedDueToInvalidPackage()); | 291 | this.messaging.Write(ErrorMessages.ValidationFailedDueToInvalidPackage()); |
290 | } | 292 | } |
291 | else if (0x658 == e.NativeErrorCode) | 293 | else if (0x658 == e.NativeErrorCode) |
292 | { | 294 | { |
293 | this.OnMessage(WixErrors.ValidationFailedDueToMultilanguageMergeModule()); | 295 | this.messaging.Write(ErrorMessages.ValidationFailedDueToMultilanguageMergeModule()); |
294 | } | 296 | } |
295 | else if (0x659 == e.NativeErrorCode) | 297 | else if (0x659 == e.NativeErrorCode) |
296 | { | 298 | { |
297 | this.OnMessage(WixWarnings.ValidationFailedDueToSystemPolicy()); | 299 | this.messaging.Write(WarningMessages.ValidationFailedDueToSystemPolicy()); |
298 | } | 300 | } |
299 | else | 301 | else |
300 | { | 302 | { |
@@ -305,7 +307,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
305 | msgTemp = String.Concat("Action - '", this.actionName, "' ", e.Message); | 307 | msgTemp = String.Concat("Action - '", this.actionName, "' ", e.Message); |
306 | } | 308 | } |
307 | 309 | ||
308 | this.OnMessage(WixErrors.Win32Exception(e.NativeErrorCode, msgTemp)); | 310 | this.messaging.Write(ErrorMessages.Win32Exception(e.NativeErrorCode, msgTemp)); |
309 | } | 311 | } |
310 | } | 312 | } |
311 | } | 313 | } |
@@ -322,16 +324,6 @@ namespace WixToolset.Core.WindowsInstaller | |||
322 | } | 324 | } |
323 | } | 325 | } |
324 | 326 | ||
325 | /// <summary> | ||
326 | /// Sends a message to the message delegate if there is one. | ||
327 | /// </summary> | ||
328 | /// <param name="mea">Message event arguments.</param> | ||
329 | public void OnMessage(MessageEventArgs e) | ||
330 | { | ||
331 | Messaging.Instance.OnMessage(e); | ||
332 | this.extension.OnMessage(e); | ||
333 | } | ||
334 | |||
335 | public static Validator CreateFromContext(IBindContext context, string cubeFilename) | 327 | public static Validator CreateFromContext(IBindContext context, string cubeFilename) |
336 | { | 328 | { |
337 | Validator validator = null; | 329 | Validator validator = null; |
@@ -339,7 +331,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
339 | // Tell the binder about the validator if validation isn't suppressed | 331 | // Tell the binder about the validator if validation isn't suppressed |
340 | if (!context.SuppressValidation) | 332 | if (!context.SuppressValidation) |
341 | { | 333 | { |
342 | validator = new Validator(); | 334 | validator = new Validator(context.Messaging); |
343 | validator.IntermediateFolder = Path.Combine(context.IntermediateFolder, "validate"); | 335 | validator.IntermediateFolder = Path.Combine(context.IntermediateFolder, "validate"); |
344 | 336 | ||
345 | // set the default cube file | 337 | // set the default cube file |
@@ -378,7 +370,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
378 | } | 370 | } |
379 | catch (WixException ex) | 371 | catch (WixException ex) |
380 | { | 372 | { |
381 | this.OnMessage(ex.Error); | 373 | this.messaging.Write(ex.Error); |
382 | } | 374 | } |
383 | 375 | ||
384 | return 1; | 376 | return 1; |