main
cs 42 lines 1.46 KB
Raw
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 Example.Extension
4 {
5 using System;
6 using System.Collections.Generic;
7 using System.Xml.Linq;
8 using WixToolset.Data.WindowsInstaller;
9 using WixToolset.Extensibility;
10
11 internal class ExampleWindowsInstallerDecompilerExtension : BaseWindowsInstallerDecompilerExtension
12 {
13 public override IReadOnlyCollection<TableDefinition> TableDefinitions => ExampleTableDefinitions.All;
14
15 public override bool TryDecompileTable(Table table)
16 {
17 switch (table.Name)
18 {
19 case "Wix4Example":
20 this.ProcessExampleTable(table);
21 return true;
22 }
23
24 return false;
25 }
26
27 private void ProcessExampleTable(Table table)
28 {
29 foreach (var row in table.Rows)
30 {
31 var componentId = row.FieldAsString(1);
32 if (this.DecompilerHelper.TryGetIndexedElement("Component", componentId, out var component))
33 {
34 component.Add(new XElement(ExampleConstants.ExampleName,
35 new XAttribute("Id", row.FieldAsString(0)),
36 new XAttribute("Value", row.FieldAsString(2))
37 ));
38 }
39 }
40 }
41 }
42 }