aboutsummaryrefslogtreecommitdiff
path: root/src/wixext/HttpDecompiler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/wixext/HttpDecompiler.cs')
-rw-r--r--src/wixext/HttpDecompiler.cs135
1 files changed, 135 insertions, 0 deletions
diff --git a/src/wixext/HttpDecompiler.cs b/src/wixext/HttpDecompiler.cs
new file mode 100644
index 00000000..043ee1e1
--- /dev/null
+++ b/src/wixext/HttpDecompiler.cs
@@ -0,0 +1,135 @@
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.Collections;
7 using System.Diagnostics;
8 using System.Globalization;
9 using WixToolset.Data;
10 using WixToolset.Extensibility;
11 using Http = WixToolset.Extensions.Serialize.Http;
12 using Wix = WixToolset.Data.Serialize;
13
14 /// <summary>
15 /// The decompiler for the WiX Toolset Http Extension.
16 /// </summary>
17 public sealed class HttpDecompiler : DecompilerExtension
18 {
19 /// <summary>
20 /// Creates a decompiler for Http Extension.
21 /// </summary>
22 public HttpDecompiler()
23 {
24 this.TableDefinitions = HttpExtensionData.GetExtensionTableDefinitions();
25 }
26
27 /// <summary>
28 /// Get the extensions library to be removed.
29 /// </summary>
30 /// <param name="tableDefinitions">Table definitions for library.</param>
31 /// <returns>Library to remove from decompiled output.</returns>
32 public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions)
33 {
34 return HttpExtensionData.GetExtensionLibrary(tableDefinitions);
35 }
36
37 /// <summary>
38 /// Decompiles an extension table.
39 /// </summary>
40 /// <param name="table">The table to decompile.</param>
41 public override void DecompileTable(Table table)
42 {
43 switch (table.Name)
44 {
45 case "WixHttpUrlReservation":
46 this.DecompileWixHttpUrlReservationTable(table);
47 break;
48 case "WixHttpUrlAce":
49 this.DecompileWixHttpUrlAceTable(table);
50 break;
51 default:
52 base.DecompileTable(table);
53 break;
54 }
55 }
56
57 /// <summary>
58 /// Decompile the WixHttpUrlReservation table.
59 /// </summary>
60 /// <param name="table">The table to decompile.</param>
61 private void DecompileWixHttpUrlReservationTable(Table table)
62 {
63 foreach (Row row in table.Rows)
64 {
65 Http.UrlReservation urlReservation = new Http.UrlReservation();
66 urlReservation.Id = (string)row[0];
67 switch((int)row[1])
68 {
69 case HttpConstants.heReplace:
70 default:
71 urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.replace;
72 break;
73 case HttpConstants.heIgnore:
74 urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.ignore;
75 break;
76 case HttpConstants.heFail:
77 urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.fail;
78 break;
79 }
80 urlReservation.Sddl = (string)row[2];
81 urlReservation.Url = (string)row[3];
82
83 Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[4]);
84 if (null != component)
85 {
86 component.AddChild(urlReservation);
87 }
88 else
89 {
90 this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component"));
91 }
92 this.Core.IndexElement(row, urlReservation);
93 }
94 }
95
96
97 /// <summary>
98 /// Decompile the WixHttpUrlAce table.
99 /// </summary>
100 /// <param name="table">The table to decompile.</param>
101 private void DecompileWixHttpUrlAceTable(Table table)
102 {
103 foreach (Row row in table.Rows)
104 {
105 Http.UrlAce urlace = new Http.UrlAce();
106 urlace.Id = (string)row[0];
107 urlace.SecurityPrincipal = (string)row[2];
108 switch (Convert.ToInt32(row[3]))
109 {
110 case HttpConstants.GENERIC_ALL:
111 default:
112 urlace.Rights = Http.UrlAce.RightsType.all;
113 break;
114 case HttpConstants.GENERIC_EXECUTE:
115 urlace.Rights = Http.UrlAce.RightsType.register;
116 break;
117 case HttpConstants.GENERIC_WRITE:
118 urlace.Rights = Http.UrlAce.RightsType.@delegate;
119 break;
120 }
121
122 string reservationId = (string)row[1];
123 Http.UrlReservation urlReservation = (Http.UrlReservation)this.Core.GetIndexedElement("WixHttpUrlReservation", reservationId);
124 if (null != urlReservation)
125 {
126 urlReservation.AddChild(urlace);
127 }
128 else
129 {
130 this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, urlace.Id, "WixHttpUrlReservation_", reservationId, "WixHttpUrlReservation"));
131 }
132 }
133 }
134 }
135}