Implement update control text
Rob Mensching committed
Jun 12, 2020 at 12:42 UTC
404e5661ee971b9b2544185c3a28b24fafc06185
3 files changed
+24
-45
src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+6
-15
@@ -325,6 +325,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind
325
command.Execute();
326
}
327
328
+ // Update control text from files on disk.
329
+ {
330
+ var command = new UpdateControlTextCommand(this.Messaging, section);
331
+ command.Execute();
332
+ }
333
+
334
// Update file sequence.
335
{
336
var command = new UpdateMediaSequencesCommand(section, fileFacades);
@@ -615,21 +621,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind
621
}
622
}
623
618
- /// <summary>
619
- /// Update Control and BBControl text by reading from files when necessary.
620
- /// </summary>
621
- /// <param name="output">Internal representation of the msi database to operate upon.</param>
622
- private void UpdateControlText(WindowsInstallerData output)
623
- {
624
- var command = new UpdateControlTextCommand();
625
- command.Messaging = this.Messaging;
626
- command.BBControlTable = output.Tables["BBControl"];
627
- command.WixBBControlTable = output.Tables["WixBBControl"];
628
- command.ControlTable = output.Tables["Control"];
629
- command.WixControlTable = output.Tables["WixControl"];
630
- command.Execute();
631
- }
632
-
624
private string ResolveMedia(MediaTuple media, string mediaLayoutDirectory, string layoutDirectory)
625
{
626
string layout = null;
src/WixToolset.Core.WindowsInstaller/Bind/UpdateControlTextCommand.cs
+16
-28
@@ -4,43 +4,33 @@ namespace WixToolset.Core.WindowsInstaller.Bind
4
{
5
using System;
6
using System.IO;
7
+ using System.Linq;
8
using WixToolset.Data;
8
- using WixToolset.Data.WindowsInstaller;
9
- using WixToolset.Data.WindowsInstaller.Rows;
9
+ using WixToolset.Data.Tuples;
10
using WixToolset.Extensibility.Services;
11
12
internal class UpdateControlTextCommand
13
{
14
- public IMessaging Messaging { private get; set; }
15
-
16
- public Table BBControlTable { private get; set; }
17
-
18
- public Table WixBBControlTable { private get; set; }
14
+ public UpdateControlTextCommand(IMessaging messaging, IntermediateSection section)
15
+ {
16
+ this.Messaging = messaging;
17
+ this.Section = section;
18
+ }
19
20
- public Table ControlTable { private get; set; }
20
+ private IMessaging Messaging { get; }
21
22
- public Table WixControlTable { private get; set; }
22
+ private IntermediateSection Section { get; }
23
24
public void Execute()
25
{
26
- if (null != this.WixBBControlTable)
26
+ foreach (var bbControl in this.Section.Tuples.OfType<BBControlTuple>().Where(t => t.SourceFile != null))
27
{
28
- RowDictionary<BBControlRow> bbControlRows = new RowDictionary<BBControlRow>(this.BBControlTable);
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
- }
28
+ bbControl.Text = this.ReadTextFile(bbControl.SourceLineNumbers, bbControl.SourceFile.Path);
29
}
30
36
- if (null != this.WixControlTable)
31
+ foreach (var control in this.Section.Tuples.OfType<ControlTuple>().Where(t => t.SourceFile != null))
32
{
38
- RowDictionary<ControlRow> controlRows = new RowDictionary<ControlRow>(this.ControlTable);
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
- }
33
+ control.Text = this.ReadTextFile(control.SourceLineNumbers, control.SourceFile.Path);
34
}
35
}
36
@@ -52,13 +42,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind
42
/// <returns>Text string read from file.</returns>
43
private string ReadTextFile(SourceLineNumber sourceLineNumbers, string source)
44
{
55
- string text = null;
56
-
45
try
46
{
59
- using (StreamReader reader = new StreamReader(source))
47
+ using (var reader = new StreamReader(source))
48
{
61
- text = reader.ReadToEnd();
49
+ return reader.ReadToEnd();
50
}
51
}
52
catch (DirectoryNotFoundException e)
@@ -78,7 +66,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
66
this.Messaging.Write(ErrorMessages.FileNotFound(sourceLineNumbers, source));
67
}
68
81
- return text;
69
+ return null;
70
}
71
}
72
}
src/WixToolset.Core/Compiler_UI.cs
+2
-2
@@ -1495,7 +1495,7 @@ namespace WixToolset.Core
1495
Sunken = sunken,
1496
Visible = !hidden,
1497
Text = text,
1498
- SourceFile = sourceFile,
1498
+ SourceFile = String.IsNullOrEmpty(sourceFile) ? null : new IntermediateFieldPathValue { Path = sourceFile }
1499
});
1500
1501
bbTuple.Set((int)BBControlTupleFields.X, x);
@@ -1524,7 +1524,7 @@ namespace WixToolset.Core
1524
Property = !String.IsNullOrEmpty(property) ? property : checkBoxPropertyRef,
1525
Text = text,
1526
Help = (null == tooltip && null == help) ? null : String.Concat(tooltip, "|", help), // Separator is required, even if only one is non-null.};
1527
- SourceFile = sourceFile
1527
+ SourceFile = String.IsNullOrEmpty(sourceFile) ? null : new IntermediateFieldPathValue { Path = sourceFile }
1528
});
1529
1530
controlTuple.Set((int)BBControlTupleFields.X, x);