aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-04-12 11:19:14 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-04-12 12:46:21 +1000
commit148ad02da05070245c8345d6650e2a70bd4706be (patch)
tree819c60d1c2b19848fb12bae9d9f7e009db387a43 /src/WixToolset.Core.WindowsInstaller
parent6d8b6f79b44b6a41a630aa3aad5a3c7f16701798 (diff)
downloadwix-148ad02da05070245c8345d6650e2a70bd4706be.tar.gz
wix-148ad02da05070245c8345d6650e2a70bd4706be.tar.bz2
wix-148ad02da05070245c8345d6650e2a70bd4706be.zip
Merge and move default tuple logic from CreateOutputFromIRCommand to WindowsInstallerBackendHelper.
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs5
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs62
2 files changed, 15 insertions, 52 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
index 5d1e89ac..489fdacb 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
@@ -33,6 +33,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
33 this.Messaging = context.ServiceProvider.GetService<IMessaging>(); 33 this.Messaging = context.ServiceProvider.GetService<IMessaging>();
34 34
35 this.BackendHelper = context.ServiceProvider.GetService<IBackendHelper>(); 35 this.BackendHelper = context.ServiceProvider.GetService<IBackendHelper>();
36 this.WindowsInstallerBackendHelper = context.ServiceProvider.GetService<IWindowsInstallerBackendHelper>();
36 37
37 this.PathResolver = this.ServiceProvider.GetService<IPathResolver>(); 38 this.PathResolver = this.ServiceProvider.GetService<IPathResolver>();
38 39
@@ -60,6 +61,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind
60 61
61 private IBackendHelper BackendHelper { get; } 62 private IBackendHelper BackendHelper { get; }
62 63
64 private IWindowsInstallerBackendHelper WindowsInstallerBackendHelper { get; }
65
63 private IPathResolver PathResolver { get; } 66 private IPathResolver PathResolver { get; }
64 67
65 private int Codepage { get; } 68 private int Codepage { get; }
@@ -343,7 +346,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
343 346
344 // Time to create the output object. Try to put as much above here as possible, updating the IR is better. 347 // Time to create the output object. Try to put as much above here as possible, updating the IR is better.
345 { 348 {
346 var command = new CreateOutputFromIRCommand(this.Messaging, section, tableDefinitions, this.BackendExtensions); 349 var command = new CreateOutputFromIRCommand(this.Messaging, section, tableDefinitions, this.BackendExtensions, this.WindowsInstallerBackendHelper);
347 command.Execute(); 350 command.Execute();
348 351
349 output = command.Output; 352 output = command.Output;
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs
index 15b53a55..c3bedfc7 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs
@@ -20,16 +20,19 @@ namespace WixToolset.Core.WindowsInstaller.Bind
20 20
21 private static readonly char[] ColonCharacter = new[] { ':' }; 21 private static readonly char[] ColonCharacter = new[] { ':' };
22 22
23 public CreateOutputFromIRCommand(IMessaging messaging, IntermediateSection section, TableDefinitionCollection tableDefinitions, IEnumerable<IWindowsInstallerBackendBinderExtension> backendExtensions) 23 public CreateOutputFromIRCommand(IMessaging messaging, IntermediateSection section, TableDefinitionCollection tableDefinitions, IEnumerable<IWindowsInstallerBackendBinderExtension> backendExtensions, IWindowsInstallerBackendHelper backendHelper)
24 { 24 {
25 this.Messaging = messaging; 25 this.Messaging = messaging;
26 this.Section = section; 26 this.Section = section;
27 this.TableDefinitions = tableDefinitions; 27 this.TableDefinitions = tableDefinitions;
28 this.BackendExtensions = backendExtensions; 28 this.BackendExtensions = backendExtensions;
29 this.BackendHelper = backendHelper;
29 } 30 }
30 31
31 private IEnumerable<IWindowsInstallerBackendBinderExtension> BackendExtensions { get; } 32 private IEnumerable<IWindowsInstallerBackendBinderExtension> BackendExtensions { get; }
32 33
34 private IWindowsInstallerBackendHelper BackendHelper { get; }
35
33 private IMessaging Messaging { get; } 36 private IMessaging Messaging { get; }
34 37
35 private TableDefinitionCollection TableDefinitions { get; } 38 private TableDefinitionCollection TableDefinitions { get; }
@@ -173,10 +176,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind
173 this.AddShortcutTuple((ShortcutTuple)tuple); 176 this.AddShortcutTuple((ShortcutTuple)tuple);
174 break; 177 break;
175 178
176 case TupleDefinitionType.SummaryInformation:
177 this.AddTupleDefaultly(tuple, tableName: "_SummaryInformation");
178 break;
179
180 case TupleDefinitionType.TextStyle: 179 case TupleDefinitionType.TextStyle:
181 this.AddTextStyleTuple((TextStyleTuple)tuple); 180 this.AddTextStyleTuple((TextStyleTuple)tuple);
182 break; 181 break;
@@ -1034,48 +1033,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind
1034 { 1033 {
1035 foreach (var extension in this.BackendExtensions) 1034 foreach (var extension in this.BackendExtensions)
1036 { 1035 {
1037 if (extension.TryAddTupleToOutput(tuple, this.Output)) 1036 if (extension.TryAddTupleToOutput(this.Section, tuple, this.Output, this.TableDefinitions))
1038 { 1037 {
1039 break; 1038 break;
1040 } 1039 }
1041 } 1040 }
1042 } 1041 }
1043 1042
1044 private void AddTupleDefaultly(IntermediateTuple tuple, string tableName = null) 1043 private void AddTupleDefaultly(IntermediateTuple tuple) =>
1045 { 1044 this.BackendHelper.TryAddTupleToOutputMatchingTableDefinitions(this.Section, tuple, this.Output, this.TableDefinitions);
1046 if (!this.TableDefinitions.TryGet(tableName ?? tuple.Definition.Name, out var tableDefinition))
1047 {
1048 return;
1049 }
1050
1051 var row = this.CreateRow(tuple, tableDefinition);
1052 var rowOffset = 0;
1053
1054 if (tableDefinition.TupleIdIsPrimaryKey)
1055 {
1056 row[0] = tuple.Id.Id;
1057 rowOffset = 1;
1058 }
1059
1060 for (var i = 0; i < tuple.Fields.Length; ++i)
1061 {
1062 if (i < tableDefinition.Columns.Length)
1063 {
1064 var column = tableDefinition.Columns[i + rowOffset];
1065
1066 switch (column.Type)
1067 {
1068 case ColumnType.Number:
1069 row[i + rowOffset] = column.Nullable ? tuple.AsNullableNumber(i) : tuple.AsNumber(i);
1070 break;
1071
1072 default:
1073 row[i + rowOffset] = tuple.AsString(i);
1074 break;
1075 }
1076 }
1077 }
1078 }
1079 1045
1080 private static OutputType SectionTypeToOutputType(SectionType type) 1046 private static OutputType SectionTypeToOutputType(SectionType type)
1081 { 1047 {
@@ -1097,17 +1063,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind
1097 } 1063 }
1098 } 1064 }
1099 1065
1100 private Row CreateRow(IntermediateTuple tuple, string tableDefinitionName) => this.CreateRow(tuple, this.TableDefinitions[tableDefinitionName]); 1066 private Row CreateRow(IntermediateTuple tuple, string tableDefinitionName) =>
1101 1067 this.CreateRow(tuple, this.TableDefinitions[tableDefinitionName]);
1102 private Row CreateRow(IntermediateTuple tuple, TableDefinition tableDefinition)
1103 {
1104 var table = this.Output.EnsureTable(tableDefinition);
1105
1106 var row = table.CreateRow(tuple.SourceLineNumbers);
1107 row.SectionId = this.Section.Id;
1108 1068
1109 return row; 1069 private Row CreateRow(IntermediateTuple tuple, TableDefinition tableDefinition) =>
1110 } 1070 this.BackendHelper.CreateRow(this.Section, tuple, this.Output, tableDefinition);
1111 1071
1112 private static string GetMsiFilenameValue(string shortName, string longName) 1072 private static string GetMsiFilenameValue(string shortName, string longName)
1113 { 1073 {