aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2020-06-03 02:19:16 -0700
committerRob Mensching <rob@firegiant.com>2020-06-03 02:23:16 -0700
commit9317f7c8ea709da55e4602eaaba06952bbf315b7 (patch)
tree51e8348f891041dcc160a6b79e8965ca6a908b9d /src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs
parentd529525a1e331f3ef9ec2707791c99bd78fdd82f (diff)
downloadwix-9317f7c8ea709da55e4602eaaba06952bbf315b7.tar.gz
wix-9317f7c8ea709da55e4602eaaba06952bbf315b7.tar.bz2
wix-9317f7c8ea709da55e4602eaaba06952bbf315b7.zip
Redesign CustomTable tuples to support resolving binary columns
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs257
1 files changed, 117 insertions, 140 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs
index eba7bdbe..d7809034 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs
@@ -32,11 +32,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind
32 public TableDefinitionCollection Execute() 32 public TableDefinitionCollection Execute()
33 { 33 {
34 var tableDefinitions = new TableDefinitionCollection(WindowsInstallerTableDefinitions.All); 34 var tableDefinitions = new TableDefinitionCollection(WindowsInstallerTableDefinitions.All);
35 var customColumnsById = this.Section.Tuples.OfType<WixCustomTableColumnTuple>().ToDictionary(t => t.Id.Id);
35 36
36 foreach (var tuple in this.Section.Tuples.OfType<WixCustomTableTuple>()) 37 if (customColumnsById.Any())
37 { 38 {
38 var customTableDefinition = this.CreateCustomTable(tuple); 39 foreach (var tuple in this.Section.Tuples.OfType<WixCustomTableTuple>())
39 tableDefinitions.Add(customTableDefinition); 40 {
41 var customTableDefinition = this.CreateCustomTable(tuple, customColumnsById);
42 tableDefinitions.Add(customTableDefinition);
43 }
40 } 44 }
41 45
42 foreach (var backendExtension in this.BackendExtensions) 46 foreach (var backendExtension in this.BackendExtensions)
@@ -56,177 +60,150 @@ namespace WixToolset.Core.WindowsInstaller.Bind
56 return this.TableDefinitions; 60 return this.TableDefinitions;
57 } 61 }
58 62
59 private TableDefinition CreateCustomTable(WixCustomTableTuple tuple) 63 private TableDefinition CreateCustomTable(WixCustomTableTuple tuple, Dictionary<string, WixCustomTableColumnTuple> customColumnsById)
60 { 64 {
61 var columnNames = tuple.ColumnNames.Split('\t'); 65 var columnNames = tuple.ColumnNamesSeparated;
62 var columnTypes = tuple.ColumnTypes.Split('\t');
63 var primaryKeys = tuple.PrimaryKeys.Split('\t');
64 var minValues = tuple.MinValues?.Split('\t');
65 var maxValues = tuple.MaxValues?.Split('\t');
66 var keyTables = tuple.KeyTables?.Split('\t');
67 var keyColumns = tuple.KeyColumns?.Split('\t');
68 var categories = tuple.Categories?.Split('\t');
69 var sets = tuple.Sets?.Split('\t');
70 var descriptions = tuple.Descriptions?.Split('\t');
71 var modularizations = tuple.Modularizations?.Split('\t');
72
73 var currentPrimaryKey = 0;
74
75 var columns = new List<ColumnDefinition>(columnNames.Length); 66 var columns = new List<ColumnDefinition>(columnNames.Length);
76 for (var i = 0; i < columnNames.Length; ++i) 67
68 foreach (var name in columnNames)
77 { 69 {
78 var name = columnNames[i]; 70 var column = customColumnsById[tuple.Id.Id + "/" + name];
71
79 var type = ColumnType.Unknown; 72 var type = ColumnType.Unknown;
80 73
81 if (columnTypes[i].StartsWith("s", StringComparison.OrdinalIgnoreCase)) 74 if (column.Type == IntermediateFieldType.String)
82 {
83 type = ColumnType.String;
84 }
85 else if (columnTypes[i].StartsWith("l", StringComparison.OrdinalIgnoreCase))
86 { 75 {
87 type = ColumnType.Localized; 76 type = column.Localizable ? ColumnType.Localized : ColumnType.String;
88 } 77 }
89 else if (columnTypes[i].StartsWith("i", StringComparison.OrdinalIgnoreCase)) 78 else if (column.Type == IntermediateFieldType.Number)
90 { 79 {
91 type = ColumnType.Number; 80 type = ColumnType.Number;
92 } 81 }
93 else if (columnTypes[i].StartsWith("v", StringComparison.OrdinalIgnoreCase)) 82 else if (column.Type == IntermediateFieldType.Path)
94 { 83 {
95 type = ColumnType.Object; 84 type = ColumnType.Object;
96 } 85 }
97 86
98 var nullable = columnTypes[i].Substring(0, 1) == columnTypes[i].Substring(0, 1).ToUpperInvariant();
99 var length = Convert.ToInt32(columnTypes[i].Substring(1), CultureInfo.InvariantCulture);
100
101 var primaryKey = false;
102 if (currentPrimaryKey < primaryKeys.Length && primaryKeys[currentPrimaryKey] == columnNames[i])
103 {
104 primaryKey = true;
105 currentPrimaryKey++;
106 }
107
108 var minValue = String.IsNullOrEmpty(minValues?[i]) ? (int?)null : Convert.ToInt32(minValues[i], CultureInfo.InvariantCulture);
109 var maxValue = String.IsNullOrEmpty(maxValues?[i]) ? (int?)null : Convert.ToInt32(maxValues[i], CultureInfo.InvariantCulture);
110 var keyColumn = String.IsNullOrEmpty(keyColumns?[i]) ? (int?)null : Convert.ToInt32(keyColumns[i], CultureInfo.InvariantCulture);
111
112 var category = ColumnCategory.Unknown; 87 var category = ColumnCategory.Unknown;
113 if (null != categories && null != categories[i] && 0 < categories[i].Length) 88 switch (column.Category)
114 { 89 {
115 switch (categories[i]) 90 case "Text":
116 { 91 category = ColumnCategory.Text;
117 case "Text": 92 break;
118 category = ColumnCategory.Text; 93 case "UpperCase":
119 break; 94 category = ColumnCategory.UpperCase;
120 case "UpperCase": 95 break;
121 category = ColumnCategory.UpperCase; 96 case "LowerCase":
122 break; 97 category = ColumnCategory.LowerCase;
123 case "LowerCase": 98 break;
124 category = ColumnCategory.LowerCase; 99 case "Integer":
125 break; 100 category = ColumnCategory.Integer;
126 case "Integer": 101 break;
127 category = ColumnCategory.Integer; 102 case "DoubleInteger":
128 break; 103 category = ColumnCategory.DoubleInteger;
129 case "DoubleInteger": 104 break;
130 category = ColumnCategory.DoubleInteger; 105 case "TimeDate":
131 break; 106 category = ColumnCategory.TimeDate;
132 case "TimeDate": 107 break;
133 category = ColumnCategory.TimeDate; 108 case "Identifier":
134 break; 109 category = ColumnCategory.Identifier;
135 case "Identifier": 110 break;
136 category = ColumnCategory.Identifier; 111 case "Property":
137 break; 112 category = ColumnCategory.Property;
138 case "Property": 113 break;
139 category = ColumnCategory.Property; 114 case "Filename":
140 break; 115 category = ColumnCategory.Filename;
141 case "Filename": 116 break;
142 category = ColumnCategory.Filename; 117 case "WildCardFilename":
143 break; 118 category = ColumnCategory.WildCardFilename;
144 case "WildCardFilename": 119 break;
145 category = ColumnCategory.WildCardFilename; 120 case "Path":
146 break; 121 category = ColumnCategory.Path;
147 case "Path": 122 break;
148 category = ColumnCategory.Path; 123 case "Paths":
149 break; 124 category = ColumnCategory.Paths;
150 case "Paths": 125 break;
151 category = ColumnCategory.Paths; 126 case "AnyPath":
152 break; 127 category = ColumnCategory.AnyPath;
153 case "AnyPath": 128 break;
154 category = ColumnCategory.AnyPath; 129 case "DefaultDir":
155 break; 130 category = ColumnCategory.DefaultDir;
156 case "DefaultDir": 131 break;
157 category = ColumnCategory.DefaultDir; 132 case "RegPath":
158 break; 133 category = ColumnCategory.RegPath;
159 case "RegPath": 134 break;
160 category = ColumnCategory.RegPath; 135 case "Formatted":
161 break; 136 category = ColumnCategory.Formatted;
162 case "Formatted": 137 break;
163 category = ColumnCategory.Formatted; 138 case "FormattedSddl":
164 break; 139 category = ColumnCategory.FormattedSDDLText;
165 case "FormattedSddl": 140 break;
166 category = ColumnCategory.FormattedSDDLText; 141 case "Template":
167 break; 142 category = ColumnCategory.Template;
168 case "Template": 143 break;
169 category = ColumnCategory.Template; 144 case "Condition":
170 break; 145 category = ColumnCategory.Condition;
171 case "Condition": 146 break;
172 category = ColumnCategory.Condition; 147 case "Guid":
173 break; 148 category = ColumnCategory.Guid;
174 case "Guid": 149 break;
175 category = ColumnCategory.Guid; 150 case "Version":
176 break; 151 category = ColumnCategory.Version;
177 case "Version": 152 break;
178 category = ColumnCategory.Version; 153 case "Language":
179 break; 154 category = ColumnCategory.Language;
180 case "Language": 155 break;
181 category = ColumnCategory.Language; 156 case "Binary":
182 break; 157 category = ColumnCategory.Binary;
183 case "Binary": 158 break;
184 category = ColumnCategory.Binary; 159 case "CustomSource":
185 break; 160 category = ColumnCategory.CustomSource;
186 case "CustomSource": 161 break;
187 category = ColumnCategory.CustomSource; 162 case "Cabinet":
188 break; 163 category = ColumnCategory.Cabinet;
189 case "Cabinet": 164 break;
190 category = ColumnCategory.Cabinet; 165 case "Shortcut":
191 break; 166 category = ColumnCategory.Shortcut;
192 case "Shortcut": 167 break;
193 category = ColumnCategory.Shortcut; 168 default:
194 break; 169 break;
195 default:
196 break;
197 }
198 } 170 }
199 171
200 var keyTable = keyTables?[i];
201 var setValue = sets?[i];
202 var description = descriptions?[i];
203 var modString = modularizations?[i];
204 var modularization = ColumnModularizeType.None; 172 var modularization = ColumnModularizeType.None;
205 173
206 switch (modString) 174 switch (column.Modularize)
207 { 175 {
208 case null: 176 case null:
209 case "None": 177 case WixCustomTableColumnModularizeType.None:
210 modularization = ColumnModularizeType.None; 178 modularization = ColumnModularizeType.None;
211 break; 179 break;
212 case "Column": 180 case WixCustomTableColumnModularizeType.Column:
213 modularization = ColumnModularizeType.Column; 181 modularization = ColumnModularizeType.Column;
214 break; 182 break;
215 case "Property": 183 case WixCustomTableColumnModularizeType.CompanionFile:
216 modularization = ColumnModularizeType.Property; 184 modularization = ColumnModularizeType.CompanionFile;
217 break; 185 break;
218 case "Condition": 186 case WixCustomTableColumnModularizeType.Condition:
219 modularization = ColumnModularizeType.Condition; 187 modularization = ColumnModularizeType.Condition;
220 break; 188 break;
221 case "CompanionFile": 189 case WixCustomTableColumnModularizeType.ControlEventArgument:
222 modularization = ColumnModularizeType.CompanionFile; 190 modularization = ColumnModularizeType.ControlEventArgument;
191 break;
192 case WixCustomTableColumnModularizeType.ControlText:
193 modularization = ColumnModularizeType.ControlText;
194 break;
195 case WixCustomTableColumnModularizeType.Icon:
196 modularization = ColumnModularizeType.Icon;
197 break;
198 case WixCustomTableColumnModularizeType.Property:
199 modularization = ColumnModularizeType.Property;
223 break; 200 break;
224 case "SemicolonDelimited": 201 case WixCustomTableColumnModularizeType.SemicolonDelimited:
225 modularization = ColumnModularizeType.SemicolonDelimited; 202 modularization = ColumnModularizeType.SemicolonDelimited;
226 break; 203 break;
227 } 204 }
228 205
229 var columnDefinition = new ColumnDefinition(name, type, length, primaryKey, nullable, category, minValue, maxValue, keyTable, keyColumn, setValue, description, modularization, ColumnType.Localized == type, true); 206 var columnDefinition = new ColumnDefinition(name, type, column.Width, column.PrimaryKey, column.Nullable, category, column.MinValue, column.MaxValue, column.KeyTable, column.KeyColumn, column.Set, column.Description, modularization, ColumnType.Localized == type, useCData: true, column.Unreal);
230 columns.Add(columnDefinition); 207 columns.Add(columnDefinition);
231 } 208 }
232 209