diff options
Diffstat (limited to 'src/wixext/DependencyWindowsInstallerBackendBinderExtension.cs')
| -rw-r--r-- | src/wixext/DependencyWindowsInstallerBackendBinderExtension.cs | 168 |
1 files changed, 0 insertions, 168 deletions
diff --git a/src/wixext/DependencyWindowsInstallerBackendBinderExtension.cs b/src/wixext/DependencyWindowsInstallerBackendBinderExtension.cs deleted file mode 100644 index f52f97f3..00000000 --- a/src/wixext/DependencyWindowsInstallerBackendBinderExtension.cs +++ /dev/null | |||
| @@ -1,168 +0,0 @@ | |||
| 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.Dependency | ||
| 4 | { | ||
| 5 | using System.Collections.Generic; | ||
| 6 | using WixToolset.Data.WindowsInstaller; | ||
| 7 | using WixToolset.Extensibility; | ||
| 8 | |||
| 9 | public class DependencyWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension | ||
| 10 | { | ||
| 11 | public override IEnumerable<TableDefinition> TableDefinitions => DependencyTableDefinitions.All; | ||
| 12 | |||
| 13 | #if TODO_DEPENDENCY_BINDER_EXTENSION | ||
| 14 | private Output output; | ||
| 15 | |||
| 16 | /// <summary> | ||
| 17 | /// Called after all output changes occur and right before the output is bound into its final format. | ||
| 18 | /// </summary> | ||
| 19 | public void Finish(Output output) | ||
| 20 | { | ||
| 21 | // Only process MSI packages. | ||
| 22 | if (OutputType.Product != output.Type) | ||
| 23 | { | ||
| 24 | return; | ||
| 25 | } | ||
| 26 | |||
| 27 | this.output = output; | ||
| 28 | |||
| 29 | Table wixDependencyTable = output.Tables["WixDependency"]; | ||
| 30 | Table wixDependencyProviderTable = output.Tables["WixDependencyProvider"]; | ||
| 31 | Table wixDependencyRefTable = output.Tables["WixDependencyRef"]; | ||
| 32 | |||
| 33 | // Make sure there's something to do. | ||
| 34 | if (null != wixDependencyRefTable) | ||
| 35 | { | ||
| 36 | KeyedRowCollection wixDependencyRows = new KeyedRowCollection(wixDependencyTable); | ||
| 37 | KeyedRowCollection wixDependencyProviderRows = new KeyedRowCollection(wixDependencyProviderTable); | ||
| 38 | |||
| 39 | // For each relationship, get the provides and requires rows to generate registry values. | ||
| 40 | foreach (Row wixDependencyRefRow in wixDependencyRefTable.Rows) | ||
| 41 | { | ||
| 42 | string providesId = (string)wixDependencyRefRow[0]; | ||
| 43 | string requiresId = (string)wixDependencyRefRow[1]; | ||
| 44 | |||
| 45 | Row wixDependencyRow = null; | ||
| 46 | if (wixDependencyRows.Contains(requiresId)) | ||
| 47 | { | ||
| 48 | wixDependencyRow = wixDependencyRows[requiresId]; | ||
| 49 | } | ||
| 50 | |||
| 51 | Row wixDependencyProviderRow = null; | ||
| 52 | if (wixDependencyProviderRows.Contains(providesId)) | ||
| 53 | { | ||
| 54 | wixDependencyProviderRow = wixDependencyProviderRows[providesId]; | ||
| 55 | } | ||
| 56 | |||
| 57 | // If we found both rows, generate the registry values. | ||
| 58 | if (null != wixDependencyRow && null != wixDependencyProviderRow) | ||
| 59 | { | ||
| 60 | // Format the root registry key using the required provider key and the current provider key. | ||
| 61 | string requiresKey = (string)wixDependencyRow[1]; | ||
| 62 | string providesKey = (string)wixDependencyProviderRow[2]; | ||
| 63 | string keyRequires = String.Format(@"{0}{1}\{2}\{3}", DependencyCommon.RegistryRoot, requiresKey, DependencyCommon.RegistryDependents, providesKey); | ||
| 64 | |||
| 65 | // Get the component ID from the provider. | ||
| 66 | string componentId = (string)wixDependencyProviderRow[1]; | ||
| 67 | |||
| 68 | Row row = this.CreateRegistryRow(wixDependencyRow); | ||
| 69 | row[0] = this.Core.CreateIdentifier("reg", providesId, requiresId, "(Default)"); | ||
| 70 | row[1] = -1; | ||
| 71 | row[2] = keyRequires; | ||
| 72 | row[3] = "*"; | ||
| 73 | row[4] = null; | ||
| 74 | row[5] = componentId; | ||
| 75 | |||
| 76 | string minVersion = (string)wixDependencyRow[2]; | ||
| 77 | if (!String.IsNullOrEmpty(minVersion)) | ||
| 78 | { | ||
| 79 | row = this.CreateRegistryRow(wixDependencyRow); | ||
| 80 | row[0] = this.Core.CreateIdentifier("reg", providesId, requiresId, "MinVersion"); | ||
| 81 | row[1] = -1; | ||
| 82 | row[2] = keyRequires; | ||
| 83 | row[3] = "MinVersion"; | ||
| 84 | row[4] = minVersion; | ||
| 85 | row[5] = componentId; | ||
| 86 | } | ||
| 87 | |||
| 88 | string maxVersion = (string)wixDependencyRow[3]; | ||
| 89 | if (!String.IsNullOrEmpty(minVersion)) | ||
| 90 | { | ||
| 91 | row = this.CreateRegistryRow(wixDependencyRow); | ||
| 92 | row[0] = this.Core.CreateIdentifier("reg", providesId, requiresId, "MaxVersion"); | ||
| 93 | row[1] = -1; | ||
| 94 | row[2] = keyRequires; | ||
| 95 | row[3] = "MaxVersion"; | ||
| 96 | row[4] = maxVersion; | ||
| 97 | row[5] = componentId; | ||
| 98 | } | ||
| 99 | |||
| 100 | if (null != wixDependencyRow[4]) | ||
| 101 | { | ||
| 102 | int attributes = (int)wixDependencyRow[4]; | ||
| 103 | |||
| 104 | row = this.CreateRegistryRow(wixDependencyRow); | ||
| 105 | row[0] = this.Core.CreateIdentifier("reg", providesId, requiresId, "Attributes"); | ||
| 106 | row[1] = -1; | ||
| 107 | row[2] = keyRequires; | ||
| 108 | row[3] = "Attributes"; | ||
| 109 | row[4] = String.Concat("#", attributes.ToString(CultureInfo.InvariantCulture.NumberFormat)); | ||
| 110 | row[5] = componentId; | ||
| 111 | } | ||
| 112 | } | ||
| 113 | } | ||
| 114 | } | ||
| 115 | } | ||
| 116 | |||
| 117 | /// <summary> | ||
| 118 | /// Creates a registry row using source information from the given <see cref="Row"/>. | ||
| 119 | /// </summary> | ||
| 120 | /// <param name="referenceRow">The <see cref="Row"/> from which the section and source line information are retrieved.</param> | ||
| 121 | /// <returns>A new Registry row.</returns> | ||
| 122 | private Row CreateRegistryRow(Row referenceRow) | ||
| 123 | { | ||
| 124 | TableDefinition tableDefinition = this.Core.TableDefinitions["Registry"]; | ||
| 125 | |||
| 126 | // Create the row from the main tables, which were populated during link anyway. | ||
| 127 | // We still associate the table with the dependency row's section to maintain servicing. | ||
| 128 | Table table = this.output.EnsureTable(tableDefinition, referenceRow.Table.Section); | ||
| 129 | Row row = table.CreateRow(referenceRow.SourceLineNumbers); | ||
| 130 | |||
| 131 | // Set the section ID for patching and return the new row. | ||
| 132 | row.SectionId = referenceRow.SectionId; | ||
| 133 | return row; | ||
| 134 | } | ||
| 135 | |||
| 136 | /// <summary> | ||
| 137 | /// A keyed collection of <see cref="Row"/> instances for O(1) lookup. | ||
| 138 | /// </summary> | ||
| 139 | private sealed class KeyedRowCollection : KeyedCollection<string, Row> | ||
| 140 | { | ||
| 141 | /// <summary> | ||
| 142 | /// Initializes the <see cref="KeyedRowCollection"/> class with all rows from the specified <paramref name="table"/>. | ||
| 143 | /// </summary> | ||
| 144 | /// <param name="table">The <see cref="Table"/> containing rows to index.</param> | ||
| 145 | internal KeyedRowCollection(Table table) | ||
| 146 | { | ||
| 147 | if (null != table) | ||
| 148 | { | ||
| 149 | foreach (Row row in table.Rows) | ||
| 150 | { | ||
| 151 | this.Add(row); | ||
| 152 | } | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | /// <summary> | ||
| 157 | /// Gets the primary key for the <see cref="Row"/>. | ||
| 158 | /// </summary> | ||
| 159 | /// <param name="row">The <see cref="Row"/> to index.</param> | ||
| 160 | /// <returns>The primary key for the <see cref="Row"/>.</returns> | ||
| 161 | protected override string GetKeyForItem(Row row) | ||
| 162 | { | ||
| 163 | return row.GetPrimaryKey('/'); | ||
| 164 | } | ||
| 165 | } | ||
| 166 | #endif | ||
| 167 | } | ||
| 168 | } | ||
