// 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 }