diff options
Diffstat (limited to 'src/WixToolset.Core.Burn')
| -rw-r--r-- | src/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs | 98 |
1 files changed, 59 insertions, 39 deletions
diff --git a/src/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs b/src/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs index 20ecd157..7fd510c6 100644 --- a/src/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs +++ b/src/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | namespace WixToolset.Core.Burn.Bind | 3 | namespace WixToolset.Core.Burn.Bind |
| 4 | { | 4 | { |
| 5 | using System; | ||
| 5 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 6 | using System.Linq; | 7 | using System.Linq; |
| 7 | using System.Text; | 8 | using System.Text; |
| @@ -37,8 +38,8 @@ namespace WixToolset.Core.Burn.Bind | |||
| 37 | public void Execute() | 38 | public void Execute() |
| 38 | { | 39 | { |
| 39 | var tuples = this.Section.Tuples.ToList(); | 40 | var tuples = this.Section.Tuples.ToList(); |
| 40 | var cellsByTableAndRowId = new Dictionary<string, List<WixCustomTableCellTuple>>(); | 41 | var cellsByCustomDataAndElementId = new Dictionary<string, List<WixBundleCustomDataCellTuple>>(); |
| 41 | var customTablesById = new Dictionary<string, WixCustomTableTuple>(); | 42 | var customDataById = new Dictionary<string, WixBundleCustomDataTuple>(); |
| 42 | 43 | ||
| 43 | foreach (var kvp in this.ExtensionSearchTuplesById) | 44 | foreach (var kvp in this.ExtensionSearchTuplesById) |
| 44 | { | 45 | { |
| @@ -63,6 +64,7 @@ namespace WixToolset.Core.Burn.Bind | |||
| 63 | case TupleDefinitionType.WixBundle: | 64 | case TupleDefinitionType.WixBundle: |
| 64 | case TupleDefinitionType.WixBundleCatalog: | 65 | case TupleDefinitionType.WixBundleCatalog: |
| 65 | case TupleDefinitionType.WixBundleContainer: | 66 | case TupleDefinitionType.WixBundleContainer: |
| 67 | case TupleDefinitionType.WixBundleCustomDataAttribute: | ||
| 66 | case TupleDefinitionType.WixBundleExePackage: | 68 | case TupleDefinitionType.WixBundleExePackage: |
| 67 | case TupleDefinitionType.WixBundleExtension: | 69 | case TupleDefinitionType.WixBundleExtension: |
| 68 | case TupleDefinitionType.WixBundleMsiFeature: | 70 | case TupleDefinitionType.WixBundleMsiFeature: |
| @@ -82,7 +84,6 @@ namespace WixToolset.Core.Burn.Bind | |||
| 82 | case TupleDefinitionType.WixBundleVariable: | 84 | case TupleDefinitionType.WixBundleVariable: |
| 83 | case TupleDefinitionType.WixChain: | 85 | case TupleDefinitionType.WixChain: |
| 84 | case TupleDefinitionType.WixComponentSearch: | 86 | case TupleDefinitionType.WixComponentSearch: |
| 85 | case TupleDefinitionType.WixCustomTableColumn: | ||
| 86 | case TupleDefinitionType.WixDependencyProvider: | 87 | case TupleDefinitionType.WixDependencyProvider: |
| 87 | case TupleDefinitionType.WixFileSearch: | 88 | case TupleDefinitionType.WixFileSearch: |
| 88 | case TupleDefinitionType.WixGroup: | 89 | case TupleDefinitionType.WixGroup: |
| @@ -95,12 +96,12 @@ namespace WixToolset.Core.Burn.Bind | |||
| 95 | case TupleDefinitionType.WixUpdateRegistration: | 96 | case TupleDefinitionType.WixUpdateRegistration: |
| 96 | break; | 97 | break; |
| 97 | 98 | ||
| 98 | case TupleDefinitionType.WixCustomTable: | 99 | case TupleDefinitionType.WixBundleCustomData: |
| 99 | unknownTuple = !this.IndexCustomTableTuple((WixCustomTableTuple)tuple, customTablesById); | 100 | unknownTuple = !this.IndexBundleCustomDataTuple((WixBundleCustomDataTuple)tuple, customDataById); |
| 100 | break; | 101 | break; |
| 101 | 102 | ||
| 102 | case TupleDefinitionType.WixCustomTableCell: | 103 | case TupleDefinitionType.WixBundleCustomDataCell: |
| 103 | this.IndexCustomTableCellTuple((WixCustomTableCellTuple)tuple, cellsByTableAndRowId); | 104 | this.IndexBundleCustomDataCellTuple((WixBundleCustomDataCellTuple)tuple, cellsByCustomDataAndElementId); |
| 104 | break; | 105 | break; |
| 105 | 106 | ||
| 106 | case TupleDefinitionType.MustBeFromAnExtension: | 107 | case TupleDefinitionType.MustBeFromAnExtension: |
| @@ -118,68 +119,87 @@ namespace WixToolset.Core.Burn.Bind | |||
| 118 | } | 119 | } |
| 119 | } | 120 | } |
| 120 | 121 | ||
| 121 | this.AddIndexedCellTuples(customTablesById, cellsByTableAndRowId); | 122 | this.AddIndexedCellTuples(customDataById, cellsByCustomDataAndElementId); |
| 122 | } | 123 | } |
| 123 | 124 | ||
| 124 | private bool IndexCustomTableTuple(WixCustomTableTuple wixCustomTableTuple, Dictionary<string, WixCustomTableTuple> customTablesById) | 125 | private bool IndexBundleCustomDataTuple(WixBundleCustomDataTuple wixBundleCustomDataTuple, Dictionary<string, WixBundleCustomDataTuple> customDataById) |
| 125 | { | 126 | { |
| 126 | if (!wixCustomTableTuple.Unreal) | 127 | switch (wixBundleCustomDataTuple.Type) |
| 127 | { | 128 | { |
| 128 | return false; | 129 | case WixBundleCustomDataType.BootstrapperApplication: |
| 130 | case WixBundleCustomDataType.BundleExtension: | ||
| 131 | break; | ||
| 132 | default: | ||
| 133 | return false; | ||
| 129 | } | 134 | } |
| 130 | 135 | ||
| 131 | var tableId = wixCustomTableTuple.Id.Id; | 136 | var customDataId = wixBundleCustomDataTuple.Id.Id; |
| 132 | customTablesById.Add(tableId, wixCustomTableTuple); | 137 | customDataById.Add(customDataId, wixBundleCustomDataTuple); |
| 133 | return true; | 138 | return true; |
| 134 | } | 139 | } |
| 135 | 140 | ||
| 136 | private void IndexCustomTableCellTuple(WixCustomTableCellTuple wixCustomTableCellTuple, Dictionary<string, List<WixCustomTableCellTuple>> cellsByTableAndRowId) | 141 | private void IndexBundleCustomDataCellTuple(WixBundleCustomDataCellTuple wixBundleCustomDataCellTuple, Dictionary<string, List<WixBundleCustomDataCellTuple>> cellsByCustomDataAndElementId) |
| 137 | { | 142 | { |
| 138 | var tableAndRowId = wixCustomTableCellTuple.TableRef + "/" + wixCustomTableCellTuple.RowId; | 143 | var tableAndRowId = wixBundleCustomDataCellTuple.CustomDataRef + "/" + wixBundleCustomDataCellTuple.ElementId; |
| 139 | if (!cellsByTableAndRowId.TryGetValue(tableAndRowId, out var cells)) | 144 | if (!cellsByCustomDataAndElementId.TryGetValue(tableAndRowId, out var cells)) |
| 140 | { | 145 | { |
| 141 | cells = new List<WixCustomTableCellTuple>(); | 146 | cells = new List<WixBundleCustomDataCellTuple>(); |
| 142 | cellsByTableAndRowId.Add(tableAndRowId, cells); | 147 | cellsByCustomDataAndElementId.Add(tableAndRowId, cells); |
| 143 | } | 148 | } |
| 144 | 149 | ||
| 145 | cells.Add(wixCustomTableCellTuple); | 150 | cells.Add(wixBundleCustomDataCellTuple); |
| 146 | } | 151 | } |
| 147 | 152 | ||
| 148 | private void AddIndexedCellTuples(Dictionary<string, WixCustomTableTuple> customTablesById, Dictionary<string, List<WixCustomTableCellTuple>> cellsByTableAndRowId) | 153 | private void AddIndexedCellTuples(Dictionary<string, WixBundleCustomDataTuple> customDataById, Dictionary<string, List<WixBundleCustomDataCellTuple>> cellsByCustomDataAndElementId) |
| 149 | { | 154 | { |
| 150 | var sb = new StringBuilder(); | 155 | foreach (var elementValues in cellsByCustomDataAndElementId.Values) |
| 151 | using (var writer = XmlWriter.Create(sb, BurnBackendHelper.WriterSettings)) | ||
| 152 | { | 156 | { |
| 153 | foreach (var rowOfCells in cellsByTableAndRowId.Values) | 157 | var elementName = elementValues[0].CustomDataRef; |
| 154 | { | 158 | var customDataTuple = customDataById[elementName]; |
| 155 | var tableId = rowOfCells[0].TableRef; | ||
| 156 | var tableTuple = customTablesById[tableId]; | ||
| 157 | |||
| 158 | if (!tableTuple.Unreal) | ||
| 159 | { | ||
| 160 | return; | ||
| 161 | } | ||
| 162 | 159 | ||
| 163 | var columnNames = tableTuple.ColumnNamesSeparated; | 160 | var attributeNames = customDataTuple.AttributeNamesSeparated; |
| 164 | 161 | ||
| 165 | var rowDataByColumn = rowOfCells.ToDictionary(t => t.ColumnRef, t => t.Data); | 162 | var elementValuesByAttribute = elementValues.ToDictionary(t => t.AttributeRef, t => t.Value); |
| 166 | 163 | ||
| 167 | writer.WriteStartElement(tableId, BurnCommon.BADataNamespace); | 164 | var sb = new StringBuilder(); |
| 165 | using (var writer = XmlWriter.Create(sb, BurnBackendHelper.WriterSettings)) | ||
| 166 | { | ||
| 167 | switch (customDataTuple.Type) | ||
| 168 | { | ||
| 169 | case WixBundleCustomDataType.BootstrapperApplication: | ||
| 170 | writer.WriteStartElement(elementName, BurnCommon.BADataNamespace); | ||
| 171 | break; | ||
| 172 | case WixBundleCustomDataType.BundleExtension: | ||
| 173 | writer.WriteStartElement(elementName, BurnCommon.BundleExtensionDataNamespace); | ||
| 174 | break; | ||
| 175 | default: | ||
| 176 | throw new NotImplementedException(); | ||
| 177 | } | ||
| 168 | 178 | ||
| 169 | // Write all row data as attributes in table column order. | 179 | // Write all row data as attributes in table column order. |
| 170 | foreach (var column in columnNames) | 180 | foreach (var attributeName in attributeNames) |
| 171 | { | 181 | { |
| 172 | if (rowDataByColumn.TryGetValue(column, out var data)) | 182 | if (elementValuesByAttribute.TryGetValue(attributeName, out var value)) |
| 173 | { | 183 | { |
| 174 | writer.WriteAttributeString(column, data); | 184 | writer.WriteAttributeString(attributeName, value); |
| 175 | } | 185 | } |
| 176 | } | 186 | } |
| 177 | 187 | ||
| 178 | writer.WriteEndElement(); | 188 | writer.WriteEndElement(); |
| 179 | } | 189 | } |
| 180 | } | ||
| 181 | 190 | ||
| 182 | this.BackendHelper.AddBootstrapperApplicationData(sb.ToString()); | 191 | switch (customDataTuple.Type) |
| 192 | { | ||
| 193 | case WixBundleCustomDataType.BootstrapperApplication: | ||
| 194 | this.BackendHelper.AddBootstrapperApplicationData(sb.ToString()); | ||
| 195 | break; | ||
| 196 | case WixBundleCustomDataType.BundleExtension: | ||
| 197 | this.BackendHelper.AddBundleExtensionData(customDataTuple.BundleExtensionRef, sb.ToString()); | ||
| 198 | break; | ||
| 199 | default: | ||
| 200 | throw new NotImplementedException(); | ||
| 201 | } | ||
| 202 | } | ||
| 183 | } | 203 | } |
| 184 | 204 | ||
| 185 | private bool AddTupleFromExtension(IntermediateTuple tuple) | 205 | private bool AddTupleFromExtension(IntermediateTuple tuple) |
