From 4194343c39fa66778a8de9804c88789bd41dae48 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 4 May 2021 22:47:19 -0700 Subject: Move Http.wixext into ext --- src/ext/Http/wixext/HttpDecompiler.cs | 137 ++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 src/ext/Http/wixext/HttpDecompiler.cs (limited to 'src/ext/Http/wixext/HttpDecompiler.cs') diff --git a/src/ext/Http/wixext/HttpDecompiler.cs b/src/ext/Http/wixext/HttpDecompiler.cs new file mode 100644 index 00000000..8991ec2f --- /dev/null +++ b/src/ext/Http/wixext/HttpDecompiler.cs @@ -0,0 +1,137 @@ +// 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.Http +{ +#if TODO_CONSIDER_DECOMPILER + using System; + using System.Collections; + using System.Diagnostics; + using System.Globalization; + using WixToolset.Data; + using WixToolset.Extensibility; + using Http = WixToolset.Extensions.Serialize.Http; + using Wix = WixToolset.Data.Serialize; + + /// + /// The decompiler for the WiX Toolset Http Extension. + /// + public sealed class HttpDecompiler : DecompilerExtension + { + /// + /// Creates a decompiler for Http Extension. + /// + public HttpDecompiler() + { + this.TableDefinitions = HttpExtensionData.GetExtensionTableDefinitions(); + } + + /// + /// Get the extensions library to be removed. + /// + /// Table definitions for library. + /// Library to remove from decompiled output. + public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) + { + return HttpExtensionData.GetExtensionLibrary(tableDefinitions); + } + + /// + /// Decompiles an extension table. + /// + /// The table to decompile. + public override void DecompileTable(Table table) + { + switch (table.Name) + { + case "WixHttpUrlReservation": + this.DecompileWixHttpUrlReservationTable(table); + break; + case "WixHttpUrlAce": + this.DecompileWixHttpUrlAceTable(table); + break; + default: + base.DecompileTable(table); + break; + } + } + + /// + /// Decompile the WixHttpUrlReservation table. + /// + /// The table to decompile. + private void DecompileWixHttpUrlReservationTable(Table table) + { + foreach (Row row in table.Rows) + { + Http.UrlReservation urlReservation = new Http.UrlReservation(); + urlReservation.Id = (string)row[0]; + switch((int)row[1]) + { + case HttpConstants.heReplace: + default: + urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.replace; + break; + case HttpConstants.heIgnore: + urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.ignore; + break; + case HttpConstants.heFail: + urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.fail; + break; + } + urlReservation.Sddl = (string)row[2]; + urlReservation.Url = (string)row[3]; + + Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[4]); + if (null != component) + { + component.AddChild(urlReservation); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component")); + } + this.Core.IndexElement(row, urlReservation); + } + } + + + /// + /// Decompile the WixHttpUrlAce table. + /// + /// The table to decompile. + private void DecompileWixHttpUrlAceTable(Table table) + { + foreach (Row row in table.Rows) + { + Http.UrlAce urlace = new Http.UrlAce(); + urlace.Id = (string)row[0]; + urlace.SecurityPrincipal = (string)row[2]; + switch (Convert.ToInt32(row[3])) + { + case HttpConstants.GENERIC_ALL: + default: + urlace.Rights = Http.UrlAce.RightsType.all; + break; + case HttpConstants.GENERIC_EXECUTE: + urlace.Rights = Http.UrlAce.RightsType.register; + break; + case HttpConstants.GENERIC_WRITE: + urlace.Rights = Http.UrlAce.RightsType.@delegate; + break; + } + + string reservationId = (string)row[1]; + Http.UrlReservation urlReservation = (Http.UrlReservation)this.Core.GetIndexedElement("WixHttpUrlReservation", reservationId); + if (null != urlReservation) + { + urlReservation.AddChild(urlace); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, urlace.Id, "WixHttpUrlReservation_", reservationId, "WixHttpUrlReservation")); + } + } + } + } +#endif +} -- cgit v1.2.3-55-g6feb