From 404e5661ee971b9b2544185c3a28b24fafc06185 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 12 Jun 2020 12:42:26 -0700 Subject: Implement update control text --- .../Bind/BindDatabaseCommand.cs | 21 +++-------- .../Bind/UpdateControlTextCommand.cs | 44 ++++++++-------------- 2 files changed, 22 insertions(+), 43 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller/Bind') diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index bdb089ee..65e4bf13 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -325,6 +325,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind command.Execute(); } + // Update control text from files on disk. + { + var command = new UpdateControlTextCommand(this.Messaging, section); + command.Execute(); + } + // Update file sequence. { var command = new UpdateMediaSequencesCommand(section, fileFacades); @@ -615,21 +621,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind } } - /// - /// Update Control and BBControl text by reading from files when necessary. - /// - /// Internal representation of the msi database to operate upon. - private void UpdateControlText(WindowsInstallerData output) - { - var command = new UpdateControlTextCommand(); - command.Messaging = this.Messaging; - command.BBControlTable = output.Tables["BBControl"]; - command.WixBBControlTable = output.Tables["WixBBControl"]; - command.ControlTable = output.Tables["Control"]; - command.WixControlTable = output.Tables["WixControl"]; - command.Execute(); - } - private string ResolveMedia(MediaTuple media, string mediaLayoutDirectory, string layoutDirectory) { string layout = null; diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateControlTextCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateControlTextCommand.cs index 3ad2470f..104a3a37 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateControlTextCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateControlTextCommand.cs @@ -4,43 +4,33 @@ namespace WixToolset.Core.WindowsInstaller.Bind { using System; using System.IO; + using System.Linq; using WixToolset.Data; - using WixToolset.Data.WindowsInstaller; - using WixToolset.Data.WindowsInstaller.Rows; + using WixToolset.Data.Tuples; using WixToolset.Extensibility.Services; internal class UpdateControlTextCommand { - public IMessaging Messaging { private get; set; } - - public Table BBControlTable { private get; set; } - - public Table WixBBControlTable { private get; set; } + public UpdateControlTextCommand(IMessaging messaging, IntermediateSection section) + { + this.Messaging = messaging; + this.Section = section; + } - public Table ControlTable { private get; set; } + private IMessaging Messaging { get; } - public Table WixControlTable { private get; set; } + private IntermediateSection Section { get; } public void Execute() { - if (null != this.WixBBControlTable) + foreach (var bbControl in this.Section.Tuples.OfType().Where(t => t.SourceFile != null)) { - RowDictionary bbControlRows = new RowDictionary(this.BBControlTable); - foreach (Row wixRow in this.WixBBControlTable.Rows) - { - BBControlRow bbControlRow = bbControlRows.Get(wixRow.GetPrimaryKey()); - bbControlRow.Text = this.ReadTextFile(bbControlRow.SourceLineNumbers, wixRow.FieldAsString(2)); - } + bbControl.Text = this.ReadTextFile(bbControl.SourceLineNumbers, bbControl.SourceFile.Path); } - if (null != this.WixControlTable) + foreach (var control in this.Section.Tuples.OfType().Where(t => t.SourceFile != null)) { - RowDictionary controlRows = new RowDictionary(this.ControlTable); - foreach (Row wixRow in this.WixControlTable.Rows) - { - ControlRow controlRow = controlRows.Get(wixRow.GetPrimaryKey()); - controlRow.Text = this.ReadTextFile(controlRow.SourceLineNumbers, wixRow.FieldAsString(2)); - } + control.Text = this.ReadTextFile(control.SourceLineNumbers, control.SourceFile.Path); } } @@ -52,13 +42,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// Text string read from file. private string ReadTextFile(SourceLineNumber sourceLineNumbers, string source) { - string text = null; - try { - using (StreamReader reader = new StreamReader(source)) + using (var reader = new StreamReader(source)) { - text = reader.ReadToEnd(); + return reader.ReadToEnd(); } } catch (DirectoryNotFoundException e) @@ -78,7 +66,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.Messaging.Write(ErrorMessages.FileNotFound(sourceLineNumbers, source)); } - return text; + return null; } } } -- cgit v1.2.3-55-g6feb