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/UpdateControlTextCommand.cs | 44 ++++++++-------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/UpdateControlTextCommand.cs') 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