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