// 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 { using System; using System.Collections; using WixToolset.Data; using WixToolset.Extensibility; using Wix = WixToolset.Data.Serialize; #if TODO /// /// The base of the decompiler. Holds some variables used by the decompiler and extensions, /// as well as some utility methods. /// internal class DecompilerCore : IDecompilerCore { private Hashtable elements; private Wix.IParentElement rootElement; private bool showPedanticMessages; private Wix.UI uiElement; /// /// Instantiate a new decompiler core. /// /// The root element of the decompiled database. /// The message handler. internal DecompilerCore(Wix.IParentElement rootElement) { this.elements = new Hashtable(); this.rootElement = rootElement; } /// /// Gets whether the decompiler core encountered an error while processing. /// /// Flag if core encountered an error during processing. public bool EncounteredError { get { return Messaging.Instance.EncounteredError; } } /// /// Gets the root element of the decompiled output. /// /// The root element of the decompiled output. public Wix.IParentElement RootElement { get { return this.rootElement; } } /// /// Gets or sets the option to show pedantic messages. /// /// The option to show pedantic messages. public bool ShowPedanticMessages { get { return this.showPedanticMessages; } set { this.showPedanticMessages = value; } } /// /// Gets the UI element. /// /// The UI element. public Wix.UI UIElement { get { if (null == this.uiElement) { this.uiElement = new Wix.UI(); this.rootElement.AddChild(this.uiElement); } return this.uiElement; } } /// /// Verifies if a filename is a valid short filename. /// /// Filename to verify. /// true if wildcards are allowed in the filename. /// True if the filename is a valid short filename public virtual bool IsValidShortFilename(string filename, bool allowWildcards) { return false; } /// /// Convert an Int32 into a DateTime. /// /// The Int32 value. /// The DateTime. public DateTime ConvertIntegerToDateTime(int value) { int date = value / 65536; int time = value % 65536; return new DateTime(1980 + (date / 512), (date % 512) / 32, date % 32, time / 2048, (time % 2048) / 32, (time % 32) * 2); } /// /// Gets the element corresponding to the row it came from. /// /// The row corresponding to the element. /// The indexed element. public Wix.ISchemaElement GetIndexedElement(Row row) { return this.GetIndexedElement(row.TableDefinition.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter)); } /// /// Gets the element corresponding to the primary key of the given table. /// /// The table corresponding to the element. /// The primary key corresponding to the element. /// The indexed element. public Wix.ISchemaElement GetIndexedElement(string table, params string[] primaryKey) { return (Wix.ISchemaElement)this.elements[String.Concat(table, ':', String.Join(DecompilerConstants.PrimaryKeyDelimiterString, primaryKey))]; } /// /// Index an element by its corresponding row. /// /// The row corresponding to the element. /// The element to index. public void IndexElement(Row row, Wix.ISchemaElement element) { this.elements.Add(String.Concat(row.TableDefinition.Name, ':', row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter)), element); } /// /// Indicates the decompiler encountered and unexpected table to decompile. /// /// Unknown decompiled table. public void UnexpectedTable(Table table) { this.OnMessage(WixErrors.TableDecompilationUnimplemented(table.Name)); } /// /// Sends a message to the message delegate if there is one. /// /// Message event arguments. public void OnMessage(MessageEventArgs e) { Messaging.Instance.OnMessage(e); } } #endif }