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 --- src/WixToolset.Core.WindowsInstaller/Differ.cs | 30 +++++++++++--------------- 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller/Differ.cs') diff --git a/src/WixToolset.Core.WindowsInstaller/Differ.cs b/src/WixToolset.Core.WindowsInstaller/Differ.cs index 9bbde302..7cc204f9 100644 --- a/src/WixToolset.Core.WindowsInstaller/Differ.cs +++ b/src/WixToolset.Core.WindowsInstaller/Differ.cs @@ -10,26 +10,29 @@ namespace WixToolset.Core.WindowsInstaller using WixToolset.Data.WindowsInstaller; using WixToolset.Data.WindowsInstaller.Rows; using WixToolset.Extensibility; + using WixToolset.Extensibility.Services; using WixToolset.Msi; /// /// Creates a transform by diffing two outputs. /// - public sealed class Differ : IMessageHandler + public sealed class Differ { private List inspectorExtensions; private bool showPedanticMessages; private bool suppressKeepingSpecialRows; private bool preserveUnchangedRows; private const char sectionDelimiter = '/'; + private readonly IMessaging messaging; private SummaryInformationStreams transformSummaryInfo; /// /// Instantiates a new Differ class. /// - public Differ() + public Differ(IMessaging messaging) { this.inspectorExtensions = new List(); + this.messaging = messaging; } /// @@ -99,17 +102,17 @@ namespace WixToolset.Core.WindowsInstaller // compare the codepages if (targetOutput.Codepage != updatedOutput.Codepage && 0 == (TransformFlags.ErrorChangeCodePage & validationFlags)) { - this.OnMessage(WixErrors.OutputCodepageMismatch(targetOutput.SourceLineNumbers, targetOutput.Codepage, updatedOutput.Codepage)); + this.messaging.Write(ErrorMessages.OutputCodepageMismatch(targetOutput.SourceLineNumbers, targetOutput.Codepage, updatedOutput.Codepage)); if (null != updatedOutput.SourceLineNumbers) { - this.OnMessage(WixErrors.OutputCodepageMismatch2(updatedOutput.SourceLineNumbers)); + this.messaging.Write(ErrorMessages.OutputCodepageMismatch2(updatedOutput.SourceLineNumbers)); } } // compare the output types if (targetOutput.Type != updatedOutput.Type) { - throw new WixException(WixErrors.OutputTypeMismatch(targetOutput.SourceLineNumbers, targetOutput.Type.ToString(), updatedOutput.Type.ToString())); + throw new WixException(ErrorMessages.OutputTypeMismatch(targetOutput.SourceLineNumbers, targetOutput.Type.ToString(), updatedOutput.Type.ToString())); } // compare the contents of the tables @@ -159,15 +162,6 @@ namespace WixToolset.Core.WindowsInstaller return transform; } - /// - /// Sends a message to the message delegate if there is one. - /// - /// Message event arguments. - public void OnMessage(MessageEventArgs e) - { - Messaging.Instance.OnMessage(e); - } - /// /// Add a row to the using the primary key. /// @@ -210,7 +204,7 @@ namespace WixToolset.Core.WindowsInstaller } else if (this.showPedanticMessages) { - this.OnMessage(WixWarnings.DuplicatePrimaryKey(row.SourceLineNumbers, primaryKey, row.Table.Name)); + this.messaging.Write(ErrorMessages.DuplicatePrimaryKey(row.SourceLineNumbers, primaryKey, row.Table.Name)); } } else // use the string representation of the row as its primary key (it may not be unique) @@ -370,7 +364,7 @@ namespace WixToolset.Core.WindowsInstaller if (0 != targetTable.Definition.CompareTo(updatedTable.Definition)) { // continue to the next table; may be more mismatches - this.OnMessage(WixErrors.DatabaseSchemaMismatch(targetOutput.SourceLineNumbers, targetTable.Name)); + this.messaging.Write(ErrorMessages.DatabaseSchemaMismatch(targetOutput.SourceLineNumbers, targetTable.Name)); } else { @@ -425,7 +419,7 @@ namespace WixToolset.Core.WindowsInstaller this.transformSummaryInfo.TargetProductCode = (string)row[1]; if ("*" == this.transformSummaryInfo.TargetProductCode) { - this.OnMessage(WixErrors.ProductCodeInvalidForTransform(row.SourceLineNumbers)); + this.messaging.Write(ErrorMessages.ProductCodeInvalidForTransform(row.SourceLineNumbers)); } } else if ("ProductVersion" == (string)row[0]) @@ -466,7 +460,7 @@ namespace WixToolset.Core.WindowsInstaller this.transformSummaryInfo.UpdatedProductCode = (string)row[1]; if ("*" == this.transformSummaryInfo.UpdatedProductCode) { - this.OnMessage(WixErrors.ProductCodeInvalidForTransform(row.SourceLineNumbers)); + this.messaging.Write(ErrorMessages.ProductCodeInvalidForTransform(row.SourceLineNumbers)); } } else if ("ProductVersion" == (string)row[0]) -- cgit v1.2.3-55-g6feb