diff options
| author | Rob Mensching <rob@firegiant.com> | 2020-06-12 12:42:26 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2020-06-13 09:22:27 -0700 |
| commit | 404e5661ee971b9b2544185c3a28b24fafc06185 (patch) | |
| tree | 52f689d1c85900f90f4685f547aeedf554e3fa7f /src/WixToolset.Core.WindowsInstaller/Bind/UpdateControlTextCommand.cs | |
| parent | 6bd3044f8710c26be93588a1405227fdeb522131 (diff) | |
| download | wix-404e5661ee971b9b2544185c3a28b24fafc06185.tar.gz wix-404e5661ee971b9b2544185c3a28b24fafc06185.tar.bz2 wix-404e5661ee971b9b2544185c3a28b24fafc06185.zip | |
Implement update control text
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/UpdateControlTextCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/UpdateControlTextCommand.cs | 44 |
1 files changed, 16 insertions, 28 deletions
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 | |||
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.IO; | 6 | using System.IO; |
| 7 | using System.Linq; | ||
| 7 | using WixToolset.Data; | 8 | using WixToolset.Data; |
| 8 | using WixToolset.Data.WindowsInstaller; | 9 | using WixToolset.Data.Tuples; |
| 9 | using WixToolset.Data.WindowsInstaller.Rows; | ||
| 10 | using WixToolset.Extensibility.Services; | 10 | using WixToolset.Extensibility.Services; |
| 11 | 11 | ||
| 12 | internal class UpdateControlTextCommand | 12 | internal class UpdateControlTextCommand |
| 13 | { | 13 | { |
| 14 | public IMessaging Messaging { private get; set; } | 14 | public UpdateControlTextCommand(IMessaging messaging, IntermediateSection section) |
| 15 | 15 | { | |
| 16 | public Table BBControlTable { private get; set; } | 16 | this.Messaging = messaging; |
| 17 | 17 | this.Section = section; | |
| 18 | public Table WixBBControlTable { private get; set; } | 18 | } |
| 19 | 19 | ||
| 20 | public Table ControlTable { private get; set; } | 20 | private IMessaging Messaging { get; } |
| 21 | 21 | ||
| 22 | public Table WixControlTable { private get; set; } | 22 | private IntermediateSection Section { get; } |
| 23 | 23 | ||
| 24 | public void Execute() | 24 | public void Execute() |
| 25 | { | 25 | { |
| 26 | if (null != this.WixBBControlTable) | 26 | foreach (var bbControl in this.Section.Tuples.OfType<BBControlTuple>().Where(t => t.SourceFile != null)) |
| 27 | { | 27 | { |
| 28 | RowDictionary<BBControlRow> bbControlRows = new RowDictionary<BBControlRow>(this.BBControlTable); | 28 | bbControl.Text = this.ReadTextFile(bbControl.SourceLineNumbers, bbControl.SourceFile.Path); |
| 29 | foreach (Row wixRow in this.WixBBControlTable.Rows) | ||
| 30 | { | ||
| 31 | BBControlRow bbControlRow = bbControlRows.Get(wixRow.GetPrimaryKey()); | ||
| 32 | bbControlRow.Text = this.ReadTextFile(bbControlRow.SourceLineNumbers, wixRow.FieldAsString(2)); | ||
| 33 | } | ||
| 34 | } | 29 | } |
| 35 | 30 | ||
| 36 | if (null != this.WixControlTable) | 31 | foreach (var control in this.Section.Tuples.OfType<ControlTuple>().Where(t => t.SourceFile != null)) |
| 37 | { | 32 | { |
| 38 | RowDictionary<ControlRow> controlRows = new RowDictionary<ControlRow>(this.ControlTable); | 33 | control.Text = this.ReadTextFile(control.SourceLineNumbers, control.SourceFile.Path); |
| 39 | foreach (Row wixRow in this.WixControlTable.Rows) | ||
| 40 | { | ||
| 41 | ControlRow controlRow = controlRows.Get(wixRow.GetPrimaryKey()); | ||
| 42 | controlRow.Text = this.ReadTextFile(controlRow.SourceLineNumbers, wixRow.FieldAsString(2)); | ||
| 43 | } | ||
| 44 | } | 34 | } |
| 45 | } | 35 | } |
| 46 | 36 | ||
| @@ -52,13 +42,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 52 | /// <returns>Text string read from file.</returns> | 42 | /// <returns>Text string read from file.</returns> |
| 53 | private string ReadTextFile(SourceLineNumber sourceLineNumbers, string source) | 43 | private string ReadTextFile(SourceLineNumber sourceLineNumbers, string source) |
| 54 | { | 44 | { |
| 55 | string text = null; | ||
| 56 | |||
| 57 | try | 45 | try |
| 58 | { | 46 | { |
| 59 | using (StreamReader reader = new StreamReader(source)) | 47 | using (var reader = new StreamReader(source)) |
| 60 | { | 48 | { |
| 61 | text = reader.ReadToEnd(); | 49 | return reader.ReadToEnd(); |
| 62 | } | 50 | } |
| 63 | } | 51 | } |
| 64 | catch (DirectoryNotFoundException e) | 52 | catch (DirectoryNotFoundException e) |
| @@ -78,7 +66,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 78 | this.Messaging.Write(ErrorMessages.FileNotFound(sourceLineNumbers, source)); | 66 | this.Messaging.Write(ErrorMessages.FileNotFound(sourceLineNumbers, source)); |
| 79 | } | 67 | } |
| 80 | 68 | ||
| 81 | return text; | 69 | return null; |
| 82 | } | 70 | } |
| 83 | } | 71 | } |
| 84 | } | 72 | } |
