From fe2f7e06c595a4e7115d83c4cc8a05b28db5002a Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 4 May 2021 22:45:02 -0700 Subject: Move DirectX.wixext into ext --- src/ext/DirectX/wixext/DirectXDecompiler.cs | 72 +++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/ext/DirectX/wixext/DirectXDecompiler.cs (limited to 'src/ext/DirectX/wixext/DirectXDecompiler.cs') diff --git a/src/ext/DirectX/wixext/DirectXDecompiler.cs b/src/ext/DirectX/wixext/DirectXDecompiler.cs new file mode 100644 index 00000000..03f90163 --- /dev/null +++ b/src/ext/DirectX/wixext/DirectXDecompiler.cs @@ -0,0 +1,72 @@ +// 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. + +namespace WixToolset.DirectX +{ +#if TODO_CONSIDER_DECOMPILER + using System; + using System.Text; + using WixToolset.Data; + using WixToolset.Extensibility; + using Wix = WixToolset.Data.Serialize; + + /// + /// The WiX Toolset DirectX Extension. + /// + public sealed class DirectXDecompiler : DecompilerExtension + { + /// + /// Get the extensions library to be removed. + /// + /// Table definitions for library. + /// Library to remove from decompiled output. + public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) + { + return DirectXExtensionData.GetExtensionLibrary(tableDefinitions); + } + + /// + /// Called at the beginning of the decompilation of a database. + /// + /// The collection of all tables. + public override void Initialize(TableIndexedCollection tables) + { + Table propertyTable = tables["Property"]; + + if (null != propertyTable) + { + foreach (Row row in propertyTable.Rows) + { + if ("SecureCustomProperties" == row[0].ToString()) + { + // if we've referenced any of the DirectX properties, add + // a PropertyRef to pick up the CA from the extension and then remove + // it from the SecureCustomExtensions property so we don't get duplicates + StringBuilder remainingProperties = new StringBuilder(); + string[] secureCustomProperties = row[1].ToString().Split(';'); + foreach (string property in secureCustomProperties) + { + if (property.StartsWith("WIX_DIRECTX_")) + { + Wix.PropertyRef propertyRef = new Wix.PropertyRef(); + propertyRef.Id = property; + this.Core.RootElement.AddChild(propertyRef); + } + else + { + if (0 < remainingProperties.Length) + { + remainingProperties.Append(";"); + } + remainingProperties.Append(property); + } + } + + row[1] = remainingProperties.ToString(); + break; + } + } + } + } + } +#endif +} -- cgit v1.2.3-55-g6feb