diff options
| author | Rob Mensching <rob@firegiant.com> | 2019-10-23 12:53:27 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2019-10-23 12:57:55 -0700 |
| commit | 752301ba571020717862d2232e3fad585de6a39a (patch) | |
| tree | a97ceeb6b762af2dd18d0d561dadeaceda3bf387 /src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs | |
| parent | 11355d03334e300886512411d4649536a5ee65e3 (diff) | |
| download | wix-752301ba571020717862d2232e3fad585de6a39a.tar.gz wix-752301ba571020717862d2232e3fad585de6a39a.tar.bz2 wix-752301ba571020717862d2232e3fad585de6a39a.zip | |
Fix custom tables, small fixes in linker and update latest Data
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs new file mode 100644 index 00000000..05f865fa --- /dev/null +++ b/src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs | |||
| @@ -0,0 +1,213 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | namespace WixToolset.Core.WindowsInstaller.Bind | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.Globalization; | ||
| 8 | using System.Linq; | ||
| 9 | using WixToolset.Data; | ||
| 10 | using WixToolset.Data.Tuples; | ||
| 11 | using WixToolset.Data.WindowsInstaller; | ||
| 12 | |||
| 13 | internal class LoadTableDefinitionsCommand | ||
| 14 | { | ||
| 15 | public LoadTableDefinitionsCommand(IntermediateSection section) => this.Section = section; | ||
| 16 | |||
| 17 | public TableDefinitionCollection TableDefinitions { get; private set; } | ||
| 18 | |||
| 19 | private IntermediateSection Section { get; } | ||
| 20 | |||
| 21 | public TableDefinitionCollection Execute() | ||
| 22 | { | ||
| 23 | var tableDefinitions = new TableDefinitionCollection(WindowsInstallerStandardInternal.GetTableDefinitions()); | ||
| 24 | |||
| 25 | foreach (var tuple in this.Section.Tuples.OfType<WixCustomTableTuple>()) | ||
| 26 | { | ||
| 27 | var customTableDefinition = this.CreateCustomTable(tuple); | ||
| 28 | tableDefinitions.Add(customTableDefinition); | ||
| 29 | } | ||
| 30 | |||
| 31 | this.TableDefinitions = tableDefinitions; | ||
| 32 | return this.TableDefinitions; | ||
| 33 | } | ||
| 34 | |||
| 35 | private TableDefinition CreateCustomTable(WixCustomTableTuple row) | ||
| 36 | { | ||
| 37 | var columnNames = row.ColumnNames.Split('\t'); | ||
| 38 | var columnTypes = row.ColumnTypes.Split('\t'); | ||
| 39 | var primaryKeys = row.PrimaryKeys.Split('\t'); | ||
| 40 | var minValues = row.MinValues?.Split('\t'); | ||
| 41 | var maxValues = row.MaxValues?.Split('\t'); | ||
| 42 | var keyTables = row.KeyTables?.Split('\t'); | ||
| 43 | var keyColumns = row.KeyColumns?.Split('\t'); | ||
| 44 | var categories = row.Categories?.Split('\t'); | ||
| 45 | var sets = row.Sets?.Split('\t'); | ||
| 46 | var descriptions = row.Descriptions?.Split('\t'); | ||
| 47 | var modularizations = row.Modularizations?.Split('\t'); | ||
| 48 | |||
| 49 | var currentPrimaryKey = 0; | ||
| 50 | |||
| 51 | var columns = new List<ColumnDefinition>(columnNames.Length); | ||
| 52 | for (var i = 0; i < columnNames.Length; ++i) | ||
| 53 | { | ||
| 54 | var name = columnNames[i]; | ||
| 55 | var type = ColumnType.Unknown; | ||
| 56 | |||
| 57 | if (columnTypes[i].StartsWith("s", StringComparison.OrdinalIgnoreCase)) | ||
| 58 | { | ||
| 59 | type = ColumnType.String; | ||
| 60 | } | ||
| 61 | else if (columnTypes[i].StartsWith("l", StringComparison.OrdinalIgnoreCase)) | ||
| 62 | { | ||
| 63 | type = ColumnType.Localized; | ||
| 64 | } | ||
| 65 | else if (columnTypes[i].StartsWith("i", StringComparison.OrdinalIgnoreCase)) | ||
| 66 | { | ||
| 67 | type = ColumnType.Number; | ||
| 68 | } | ||
| 69 | else if (columnTypes[i].StartsWith("v", StringComparison.OrdinalIgnoreCase)) | ||
| 70 | { | ||
| 71 | type = ColumnType.Object; | ||
| 72 | } | ||
| 73 | |||
| 74 | var nullable = columnTypes[i].Substring(0, 1) == columnTypes[i].Substring(0, 1).ToUpperInvariant(); | ||
| 75 | var length = Convert.ToInt32(columnTypes[i].Substring(1), CultureInfo.InvariantCulture); | ||
| 76 | |||
| 77 | var primaryKey = false; | ||
| 78 | if (currentPrimaryKey < primaryKeys.Length && primaryKeys[currentPrimaryKey] == columnNames[i]) | ||
| 79 | { | ||
| 80 | primaryKey = true; | ||
| 81 | currentPrimaryKey++; | ||
| 82 | } | ||
| 83 | |||
| 84 | var minValue = String.IsNullOrEmpty(minValues?[i]) ? (int?)null : Convert.ToInt32(minValues[i], CultureInfo.InvariantCulture); | ||
| 85 | var maxValue = String.IsNullOrEmpty(maxValues?[i]) ? (int?)null : Convert.ToInt32(maxValues[i], CultureInfo.InvariantCulture); | ||
| 86 | var keyColumn = String.IsNullOrEmpty(keyColumns?[i]) ? (int?)null : Convert.ToInt32(keyColumns[i], CultureInfo.InvariantCulture); | ||
| 87 | |||
| 88 | var category = ColumnCategory.Unknown; | ||
| 89 | if (null != categories && null != categories[i] && 0 < categories[i].Length) | ||
| 90 | { | ||
| 91 | switch (categories[i]) | ||
| 92 | { | ||
| 93 | case "Text": | ||
| 94 | category = ColumnCategory.Text; | ||
| 95 | break; | ||
| 96 | case "UpperCase": | ||
| 97 | category = ColumnCategory.UpperCase; | ||
| 98 | break; | ||
| 99 | case "LowerCase": | ||
| 100 | category = ColumnCategory.LowerCase; | ||
| 101 | break; | ||
| 102 | case "Integer": | ||
| 103 | category = ColumnCategory.Integer; | ||
| 104 | break; | ||
| 105 | case "DoubleInteger": | ||
| 106 | category = ColumnCategory.DoubleInteger; | ||
| 107 | break; | ||
| 108 | case "TimeDate": | ||
| 109 | category = ColumnCategory.TimeDate; | ||
| 110 | break; | ||
| 111 | case "Identifier": | ||
| 112 | category = ColumnCategory.Identifier; | ||
| 113 | break; | ||
| 114 | case "Property": | ||
| 115 | category = ColumnCategory.Property; | ||
| 116 | break; | ||
| 117 | case "Filename": | ||
| 118 | category = ColumnCategory.Filename; | ||
| 119 | break; | ||
| 120 | case "WildCardFilename": | ||
| 121 | category = ColumnCategory.WildCardFilename; | ||
| 122 | break; | ||
| 123 | case "Path": | ||
| 124 | category = ColumnCategory.Path; | ||
| 125 | break; | ||
| 126 | case "Paths": | ||
| 127 | category = ColumnCategory.Paths; | ||
| 128 | break; | ||
| 129 | case "AnyPath": | ||
| 130 | category = ColumnCategory.AnyPath; | ||
| 131 | break; | ||
| 132 | case "DefaultDir": | ||
| 133 | category = ColumnCategory.DefaultDir; | ||
| 134 | break; | ||
| 135 | case "RegPath": | ||
| 136 | category = ColumnCategory.RegPath; | ||
| 137 | break; | ||
| 138 | case "Formatted": | ||
| 139 | category = ColumnCategory.Formatted; | ||
| 140 | break; | ||
| 141 | case "FormattedSddl": | ||
| 142 | category = ColumnCategory.FormattedSDDLText; | ||
| 143 | break; | ||
| 144 | case "Template": | ||
| 145 | category = ColumnCategory.Template; | ||
| 146 | break; | ||
| 147 | case "Condition": | ||
| 148 | category = ColumnCategory.Condition; | ||
| 149 | break; | ||
| 150 | case "Guid": | ||
| 151 | category = ColumnCategory.Guid; | ||
| 152 | break; | ||
| 153 | case "Version": | ||
| 154 | category = ColumnCategory.Version; | ||
| 155 | break; | ||
| 156 | case "Language": | ||
| 157 | category = ColumnCategory.Language; | ||
| 158 | break; | ||
| 159 | case "Binary": | ||
| 160 | category = ColumnCategory.Binary; | ||
| 161 | break; | ||
| 162 | case "CustomSource": | ||
| 163 | category = ColumnCategory.CustomSource; | ||
| 164 | break; | ||
| 165 | case "Cabinet": | ||
| 166 | category = ColumnCategory.Cabinet; | ||
| 167 | break; | ||
| 168 | case "Shortcut": | ||
| 169 | category = ColumnCategory.Shortcut; | ||
| 170 | break; | ||
| 171 | default: | ||
| 172 | break; | ||
| 173 | } | ||
| 174 | } | ||
| 175 | |||
| 176 | var keyTable = keyTables?[i]; | ||
| 177 | var setValue = sets?[i]; | ||
| 178 | var description = descriptions?[i]; | ||
| 179 | var modString = modularizations?[i]; | ||
| 180 | var modularization = ColumnModularizeType.None; | ||
| 181 | |||
| 182 | switch (modString) | ||
| 183 | { | ||
| 184 | case null: | ||
| 185 | case "None": | ||
| 186 | modularization = ColumnModularizeType.None; | ||
| 187 | break; | ||
| 188 | case "Column": | ||
| 189 | modularization = ColumnModularizeType.Column; | ||
| 190 | break; | ||
| 191 | case "Property": | ||
| 192 | modularization = ColumnModularizeType.Property; | ||
| 193 | break; | ||
| 194 | case "Condition": | ||
| 195 | modularization = ColumnModularizeType.Condition; | ||
| 196 | break; | ||
| 197 | case "CompanionFile": | ||
| 198 | modularization = ColumnModularizeType.CompanionFile; | ||
| 199 | break; | ||
| 200 | case "SemicolonDelimited": | ||
| 201 | modularization = ColumnModularizeType.SemicolonDelimited; | ||
| 202 | break; | ||
| 203 | } | ||
| 204 | |||
| 205 | var columnDefinition = new ColumnDefinition(name, type, length, primaryKey, nullable, category, minValue, maxValue, keyTable, keyColumn, setValue, description, modularization, ColumnType.Localized == type, true); | ||
| 206 | columns.Add(columnDefinition); | ||
| 207 | } | ||
| 208 | |||
| 209 | var customTable = new TableDefinition(row.Id.Id, columns/*, unreal: bootstrapperApplicationData, bootstrapperApplicationData*/); | ||
| 210 | return customTable; | ||
| 211 | } | ||
| 212 | } | ||
| 213 | } | ||
