From 155a6e96346e0cb3d9ab6f5372fa29b46ebaee89 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 19 Dec 2017 12:25:40 -0800 Subject: Integrate simplified message handling --- .../Bind/GenerateDatabaseCommand.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs') diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs index e4e66559..ee7cc61b 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs @@ -13,6 +13,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Msi; using WixToolset.Core.Native; using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility.Services; internal class GenerateDatabaseCommand { @@ -25,6 +26,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// public bool KeepAddedColumns { private get; set; } + public IMessaging Messaging { private get; set; } + public Output Output { private get; set; } public string OutputPath { private get; set; } @@ -177,7 +180,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind try { //db.ImportTable(this.Output.Codepage, importTable, baseDirectory, this.KeepAddedColumns); - var command = new CreateIdtFileCommand(importTable, this.Output.Codepage, baseDirectory, this.KeepAddedColumns); + var command = new CreateIdtFileCommand(this.Messaging, importTable, this.Output.Codepage, baseDirectory, this.KeepAddedColumns); command.Execute(); db.Import(command.IdtPath); @@ -262,11 +265,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (0xA1 == e.NativeErrorCode) // ERROR_BAD_PATHNAME { - throw new WixException(WixErrors.FileNotFound(row.SourceLineNumbers, (string)row[i])); + throw new WixException(ErrorMessages.FileNotFound(row.SourceLineNumbers, (string)row[i])); } else { - throw new WixException(WixErrors.Win32Exception(e.NativeErrorCode, e.Message)); + throw new WixException(ErrorMessages.Win32Exception(e.NativeErrorCode, e.Message)); } } } @@ -279,7 +282,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // check for a stream name that is more than 62 characters long (the maximum allowed length) if (needStream && MsiInterop.MsiMaxStreamNameLength < streamName.Length) { - Messaging.Instance.OnMessage(WixErrors.StreamNameTooLong(row.SourceLineNumbers, table.Name, streamName.ToString(), streamName.Length)); + this.Messaging.Write(ErrorMessages.StreamNameTooLong(row.SourceLineNumbers, table.Name, streamName.ToString(), streamName.Length)); } else // add the row to the database { @@ -309,7 +312,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Bind the transform. this.BindTransform(subStorage.Data, transformFile); - if (Messaging.Instance.EncounteredError) + if (this.Messaging.EncounteredError) { continue; } @@ -338,7 +341,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind private void BindTransform(Output transform, string outputPath) { - BindTransformCommand command = new BindTransformCommand(); + var command = new BindTransformCommand(); + command.Messaging = this.Messaging; command.Extensions = this.Extensions; command.TempFilesLocation = this.TempFilesLocation; command.Transform = transform; @@ -372,7 +376,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind catch (WixInvalidIdtException) { // the IDT should be valid, so an invalid code page was given - throw new WixException(WixErrors.IllegalCodepage(codepage)); + throw new WixException(ErrorMessages.IllegalCodepage(codepage)); } } } -- cgit v1.2.3-55-g6feb