From abff61df823505abc01776cec7b207501c671bf2 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 19 Jun 2020 13:52:20 +1000 Subject: Implement BundleCustomData. Remove Unreal from CustomTable. --- .../Bind/GenerateManifestDataFromIRCommand.cs | 98 +++++++++++++--------- 1 file changed, 59 insertions(+), 39 deletions(-) (limited to 'src/WixToolset.Core.Burn') 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 @@ namespace WixToolset.Core.Burn.Bind { + using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -37,8 +38,8 @@ namespace WixToolset.Core.Burn.Bind public void Execute() { var tuples = this.Section.Tuples.ToList(); - var cellsByTableAndRowId = new Dictionary>(); - var customTablesById = new Dictionary(); + var cellsByCustomDataAndElementId = new Dictionary>(); + var customDataById = new Dictionary(); foreach (var kvp in this.ExtensionSearchTuplesById) { @@ -63,6 +64,7 @@ namespace WixToolset.Core.Burn.Bind case TupleDefinitionType.WixBundle: case TupleDefinitionType.WixBundleCatalog: case TupleDefinitionType.WixBundleContainer: + case TupleDefinitionType.WixBundleCustomDataAttribute: case TupleDefinitionType.WixBundleExePackage: case TupleDefinitionType.WixBundleExtension: case TupleDefinitionType.WixBundleMsiFeature: @@ -82,7 +84,6 @@ namespace WixToolset.Core.Burn.Bind case TupleDefinitionType.WixBundleVariable: case TupleDefinitionType.WixChain: case TupleDefinitionType.WixComponentSearch: - case TupleDefinitionType.WixCustomTableColumn: case TupleDefinitionType.WixDependencyProvider: case TupleDefinitionType.WixFileSearch: case TupleDefinitionType.WixGroup: @@ -95,12 +96,12 @@ namespace WixToolset.Core.Burn.Bind case TupleDefinitionType.WixUpdateRegistration: break; - case TupleDefinitionType.WixCustomTable: - unknownTuple = !this.IndexCustomTableTuple((WixCustomTableTuple)tuple, customTablesById); + case TupleDefinitionType.WixBundleCustomData: + unknownTuple = !this.IndexBundleCustomDataTuple((WixBundleCustomDataTuple)tuple, customDataById); break; - case TupleDefinitionType.WixCustomTableCell: - this.IndexCustomTableCellTuple((WixCustomTableCellTuple)tuple, cellsByTableAndRowId); + case TupleDefinitionType.WixBundleCustomDataCell: + this.IndexBundleCustomDataCellTuple((WixBundleCustomDataCellTuple)tuple, cellsByCustomDataAndElementId); break; case TupleDefinitionType.MustBeFromAnExtension: @@ -118,68 +119,87 @@ namespace WixToolset.Core.Burn.Bind } } - this.AddIndexedCellTuples(customTablesById, cellsByTableAndRowId); + this.AddIndexedCellTuples(customDataById, cellsByCustomDataAndElementId); } - private bool IndexCustomTableTuple(WixCustomTableTuple wixCustomTableTuple, Dictionary customTablesById) + private bool IndexBundleCustomDataTuple(WixBundleCustomDataTuple wixBundleCustomDataTuple, Dictionary customDataById) { - if (!wixCustomTableTuple.Unreal) + switch (wixBundleCustomDataTuple.Type) { - return false; + case WixBundleCustomDataType.BootstrapperApplication: + case WixBundleCustomDataType.BundleExtension: + break; + default: + return false; } - var tableId = wixCustomTableTuple.Id.Id; - customTablesById.Add(tableId, wixCustomTableTuple); + var customDataId = wixBundleCustomDataTuple.Id.Id; + customDataById.Add(customDataId, wixBundleCustomDataTuple); return true; } - private void IndexCustomTableCellTuple(WixCustomTableCellTuple wixCustomTableCellTuple, Dictionary> cellsByTableAndRowId) + private void IndexBundleCustomDataCellTuple(WixBundleCustomDataCellTuple wixBundleCustomDataCellTuple, Dictionary> cellsByCustomDataAndElementId) { - var tableAndRowId = wixCustomTableCellTuple.TableRef + "/" + wixCustomTableCellTuple.RowId; - if (!cellsByTableAndRowId.TryGetValue(tableAndRowId, out var cells)) + var tableAndRowId = wixBundleCustomDataCellTuple.CustomDataRef + "/" + wixBundleCustomDataCellTuple.ElementId; + if (!cellsByCustomDataAndElementId.TryGetValue(tableAndRowId, out var cells)) { - cells = new List(); - cellsByTableAndRowId.Add(tableAndRowId, cells); + cells = new List(); + cellsByCustomDataAndElementId.Add(tableAndRowId, cells); } - cells.Add(wixCustomTableCellTuple); + cells.Add(wixBundleCustomDataCellTuple); } - private void AddIndexedCellTuples(Dictionary customTablesById, Dictionary> cellsByTableAndRowId) + private void AddIndexedCellTuples(Dictionary customDataById, Dictionary> cellsByCustomDataAndElementId) { - var sb = new StringBuilder(); - using (var writer = XmlWriter.Create(sb, BurnBackendHelper.WriterSettings)) + foreach (var elementValues in cellsByCustomDataAndElementId.Values) { - foreach (var rowOfCells in cellsByTableAndRowId.Values) - { - var tableId = rowOfCells[0].TableRef; - var tableTuple = customTablesById[tableId]; - - if (!tableTuple.Unreal) - { - return; - } + var elementName = elementValues[0].CustomDataRef; + var customDataTuple = customDataById[elementName]; - var columnNames = tableTuple.ColumnNamesSeparated; + var attributeNames = customDataTuple.AttributeNamesSeparated; - var rowDataByColumn = rowOfCells.ToDictionary(t => t.ColumnRef, t => t.Data); + var elementValuesByAttribute = elementValues.ToDictionary(t => t.AttributeRef, t => t.Value); - writer.WriteStartElement(tableId, BurnCommon.BADataNamespace); + var sb = new StringBuilder(); + using (var writer = XmlWriter.Create(sb, BurnBackendHelper.WriterSettings)) + { + switch (customDataTuple.Type) + { + case WixBundleCustomDataType.BootstrapperApplication: + writer.WriteStartElement(elementName, BurnCommon.BADataNamespace); + break; + case WixBundleCustomDataType.BundleExtension: + writer.WriteStartElement(elementName, BurnCommon.BundleExtensionDataNamespace); + break; + default: + throw new NotImplementedException(); + } // Write all row data as attributes in table column order. - foreach (var column in columnNames) + foreach (var attributeName in attributeNames) { - if (rowDataByColumn.TryGetValue(column, out var data)) + if (elementValuesByAttribute.TryGetValue(attributeName, out var value)) { - writer.WriteAttributeString(column, data); + writer.WriteAttributeString(attributeName, value); } } writer.WriteEndElement(); } - } - this.BackendHelper.AddBootstrapperApplicationData(sb.ToString()); + switch (customDataTuple.Type) + { + case WixBundleCustomDataType.BootstrapperApplication: + this.BackendHelper.AddBootstrapperApplicationData(sb.ToString()); + break; + case WixBundleCustomDataType.BundleExtension: + this.BackendHelper.AddBundleExtensionData(customDataTuple.BundleExtensionRef, sb.ToString()); + break; + default: + throw new NotImplementedException(); + } + } } private bool AddTupleFromExtension(IntermediateTuple tuple) -- cgit v1.2.3-55-g6feb