| 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.DirectX |
| 4 | { |
| 5 | #if TODO_CONSIDER_DECOMPILER |
| 6 | using System; |
| 7 | using System.Text; |
| 8 | using WixToolset.Data; |
| 9 | using WixToolset.Extensibility; |
| 10 | using Wix = WixToolset.Data.Serialize; |
| 11 | |
| 12 | /// <summary> |
| 13 | /// The WiX Toolset DirectX Extension. |
| 14 | /// </summary> |
| 15 | public sealed class DirectXDecompiler : DecompilerExtension |
| 16 | { |
| 17 | /// <summary> |
| 18 | /// Get the extensions library to be removed. |
| 19 | /// </summary> |
| 20 | /// <param name="tableDefinitions">Table definitions for library.</param> |
| 21 | /// <returns>Library to remove from decompiled output.</returns> |
| 22 | public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) |
| 23 | { |
| 24 | return DirectXExtensionData.GetExtensionLibrary(tableDefinitions); |
| 25 | } |
| 26 | |
| 27 | /// <summary> |
| 28 | /// Called at the beginning of the decompilation of a database. |
| 29 | /// </summary> |
| 30 | /// <param name="tables">The collection of all tables.</param> |
| 31 | public override void Initialize(TableIndexedCollection tables) |
| 32 | { |
| 33 | Table propertyTable = tables["Property"]; |
| 34 | |
| 35 | if (null != propertyTable) |
| 36 | { |
| 37 | foreach (Row row in propertyTable.Rows) |
| 38 | { |
| 39 | if ("SecureCustomProperties" == row[0].ToString()) |
| 40 | { |
| 41 | // if we've referenced any of the DirectX properties, add |
| 42 | // a PropertyRef to pick up the CA from the extension and then remove |
| 43 | // it from the SecureCustomExtensions property so we don't get duplicates |
| 44 | StringBuilder remainingProperties = new StringBuilder(); |
| 45 | string[] secureCustomProperties = row[1].ToString().Split(';'); |
| 46 | foreach (string property in secureCustomProperties) |
| 47 | { |
| 48 | if (property.StartsWith("WIX_DIRECTX_")) |
| 49 | { |
| 50 | Wix.PropertyRef propertyRef = new Wix.PropertyRef(); |
| 51 | propertyRef.Id = property; |
| 52 | this.Core.RootElement.AddChild(propertyRef); |
| 53 | } |
| 54 | else |
| 55 | { |
| 56 | if (0 < remainingProperties.Length) |
| 57 | { |
| 58 | remainingProperties.Append(";"); |
| 59 | } |
| 60 | remainingProperties.Append(property); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | row[1] = remainingProperties.ToString(); |
| 65 | break; |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | #endif |
| 72 | } |