diff options
| author | Rob Mensching <rob@firegiant.com> | 2018-10-24 21:06:51 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@robmensching.com> | 2018-10-24 21:17:34 -0700 |
| commit | 822d917960cbd35f506598af4baa6a20ad4b447e (patch) | |
| tree | 0d4cf39e25f5fe213bbeac2fb546d2aa86b172db /src/WixToolset.Core.WindowsInstaller/Decompile/DecompilerCore.cs | |
| parent | 7a2859709034f7f4f048a0757779a6e2fee6df5b (diff) | |
| download | wix-822d917960cbd35f506598af4baa6a20ad4b447e.tar.gz wix-822d917960cbd35f506598af4baa6a20ad4b447e.tar.bz2 wix-822d917960cbd35f506598af4baa6a20ad4b447e.zip | |
Re-introduce "decompile" to backend
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Decompile/DecompilerCore.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Decompile/DecompilerCore.cs | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Decompile/DecompilerCore.cs b/src/WixToolset.Core.WindowsInstaller/Decompile/DecompilerCore.cs new file mode 100644 index 00000000..17c97e09 --- /dev/null +++ b/src/WixToolset.Core.WindowsInstaller/Decompile/DecompilerCore.cs | |||
| @@ -0,0 +1,110 @@ | |||
| 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 WixToolset | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections; | ||
| 7 | using WixToolset.Data.WindowsInstaller; | ||
| 8 | using WixToolset.Extensibility; | ||
| 9 | using Wix = WixToolset.Data.Serialize; | ||
| 10 | |||
| 11 | /// <summary> | ||
| 12 | /// The base of the decompiler. Holds some variables used by the decompiler and extensions, | ||
| 13 | /// as well as some utility methods. | ||
| 14 | /// </summary> | ||
| 15 | internal class DecompilerCore | ||
| 16 | { | ||
| 17 | private readonly Hashtable elements; | ||
| 18 | private Wix.UI uiElement; | ||
| 19 | |||
| 20 | /// <summary> | ||
| 21 | /// Instantiate a new decompiler core. | ||
| 22 | /// </summary> | ||
| 23 | /// <param name="rootElement">The root element of the decompiled database.</param> | ||
| 24 | /// <param name="messageHandler">The message handler.</param> | ||
| 25 | internal DecompilerCore(Wix.IParentElement rootElement) | ||
| 26 | { | ||
| 27 | this.elements = new Hashtable(); | ||
| 28 | this.RootElement = rootElement; | ||
| 29 | } | ||
| 30 | |||
| 31 | /// <summary> | ||
| 32 | /// Gets the root element of the decompiled output. | ||
| 33 | /// </summary> | ||
| 34 | /// <value>The root element of the decompiled output.</value> | ||
| 35 | public Wix.IParentElement RootElement { get; } | ||
| 36 | |||
| 37 | /// <summary> | ||
| 38 | /// Gets the UI element. | ||
| 39 | /// </summary> | ||
| 40 | /// <value>The UI element.</value> | ||
| 41 | public Wix.UI UIElement | ||
| 42 | { | ||
| 43 | get | ||
| 44 | { | ||
| 45 | if (null == this.uiElement) | ||
| 46 | { | ||
| 47 | this.uiElement = new Wix.UI(); | ||
| 48 | this.RootElement.AddChild(this.uiElement); | ||
| 49 | } | ||
| 50 | |||
| 51 | return this.uiElement; | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | /// <summary> | ||
| 56 | /// Verifies if a filename is a valid short filename. | ||
| 57 | /// </summary> | ||
| 58 | /// <param name="filename">Filename to verify.</param> | ||
| 59 | /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param> | ||
| 60 | /// <returns>True if the filename is a valid short filename</returns> | ||
| 61 | public virtual bool IsValidShortFilename(string filename, bool allowWildcards) | ||
| 62 | { | ||
| 63 | return false; | ||
| 64 | } | ||
| 65 | |||
| 66 | /// <summary> | ||
| 67 | /// Convert an Int32 into a DateTime. | ||
| 68 | /// </summary> | ||
| 69 | /// <param name="value">The Int32 value.</param> | ||
| 70 | /// <returns>The DateTime.</returns> | ||
| 71 | public DateTime ConvertIntegerToDateTime(int value) | ||
| 72 | { | ||
| 73 | var date = value / 65536; | ||
| 74 | var time = value % 65536; | ||
| 75 | |||
| 76 | return new DateTime(1980 + (date / 512), (date % 512) / 32, date % 32, time / 2048, (time % 2048) / 32, (time % 32) * 2); | ||
| 77 | } | ||
| 78 | |||
| 79 | /// <summary> | ||
| 80 | /// Gets the element corresponding to the row it came from. | ||
| 81 | /// </summary> | ||
| 82 | /// <param name="row">The row corresponding to the element.</param> | ||
| 83 | /// <returns>The indexed element.</returns> | ||
| 84 | public Wix.ISchemaElement GetIndexedElement(Row row) | ||
| 85 | { | ||
| 86 | return this.GetIndexedElement(row.TableDefinition.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter)); | ||
| 87 | } | ||
| 88 | |||
| 89 | /// <summary> | ||
| 90 | /// Gets the element corresponding to the primary key of the given table. | ||
| 91 | /// </summary> | ||
| 92 | /// <param name="table">The table corresponding to the element.</param> | ||
| 93 | /// <param name="primaryKey">The primary key corresponding to the element.</param> | ||
| 94 | /// <returns>The indexed element.</returns> | ||
| 95 | public Wix.ISchemaElement GetIndexedElement(string table, params string[] primaryKey) | ||
| 96 | { | ||
| 97 | return (Wix.ISchemaElement)this.elements[String.Concat(table, ':', String.Join(DecompilerConstants.PrimaryKeyDelimiterString, primaryKey))]; | ||
| 98 | } | ||
| 99 | |||
| 100 | /// <summary> | ||
| 101 | /// Index an element by its corresponding row. | ||
| 102 | /// </summary> | ||
| 103 | /// <param name="row">The row corresponding to the element.</param> | ||
| 104 | /// <param name="element">The element to index.</param> | ||
| 105 | public void IndexElement(Row row, Wix.ISchemaElement element) | ||
| 106 | { | ||
| 107 | this.elements.Add(String.Concat(row.TableDefinition.Name, ':', row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter)), element); | ||
| 108 | } | ||
| 109 | } | ||
| 110 | } | ||
