aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller/DecompilerCore.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/DecompilerCore.cs')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/DecompilerCore.cs154
1 files changed, 154 insertions, 0 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/DecompilerCore.cs b/src/WixToolset.Core.WindowsInstaller/DecompilerCore.cs
new file mode 100644
index 00000000..2be986fc
--- /dev/null
+++ b/src/WixToolset.Core.WindowsInstaller/DecompilerCore.cs
@@ -0,0 +1,154 @@
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
4{
5 using System;
6 using System.Collections;
7 using WixToolset.Data;
8 using WixToolset.Extensibility;
9 using Wix = WixToolset.Data.Serialize;
10
11#if TODO
12 /// <summary>
13 /// The base of the decompiler. Holds some variables used by the decompiler and extensions,
14 /// as well as some utility methods.
15 /// </summary>
16 internal class DecompilerCore : IDecompilerCore
17 {
18 private Hashtable elements;
19 private Wix.IParentElement rootElement;
20 private bool showPedanticMessages;
21 private Wix.UI uiElement;
22
23 /// <summary>
24 /// Instantiate a new decompiler core.
25 /// </summary>
26 /// <param name="rootElement">The root element of the decompiled database.</param>
27 /// <param name="messageHandler">The message handler.</param>
28 internal DecompilerCore(Wix.IParentElement rootElement)
29 {
30 this.elements = new Hashtable();
31 this.rootElement = rootElement;
32 }
33
34 /// <summary>
35 /// Gets whether the decompiler core encountered an error while processing.
36 /// </summary>
37 /// <value>Flag if core encountered an error during processing.</value>
38 public bool EncounteredError
39 {
40 get { return Messaging.Instance.EncounteredError; }
41 }
42
43 /// <summary>
44 /// Gets the root element of the decompiled output.
45 /// </summary>
46 /// <value>The root element of the decompiled output.</value>
47 public Wix.IParentElement RootElement
48 {
49 get { return this.rootElement; }
50 }
51
52 /// <summary>
53 /// Gets or sets the option to show pedantic messages.
54 /// </summary>
55 /// <value>The option to show pedantic messages.</value>
56 public bool ShowPedanticMessages
57 {
58 get { return this.showPedanticMessages; }
59 set { this.showPedanticMessages = value; }
60 }
61
62 /// <summary>
63 /// Gets the UI element.
64 /// </summary>
65 /// <value>The UI element.</value>
66 public Wix.UI UIElement
67 {
68 get
69 {
70 if (null == this.uiElement)
71 {
72 this.uiElement = new Wix.UI();
73 this.rootElement.AddChild(this.uiElement);
74 }
75
76 return this.uiElement;
77 }
78 }
79
80 /// <summary>
81 /// Verifies if a filename is a valid short filename.
82 /// </summary>
83 /// <param name="filename">Filename to verify.</param>
84 /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param>
85 /// <returns>True if the filename is a valid short filename</returns>
86 public virtual bool IsValidShortFilename(string filename, bool allowWildcards)
87 {
88 return false;
89 }
90
91 /// <summary>
92 /// Convert an Int32 into a DateTime.
93 /// </summary>
94 /// <param name="value">The Int32 value.</param>
95 /// <returns>The DateTime.</returns>
96 public DateTime ConvertIntegerToDateTime(int value)
97 {
98 int date = value / 65536;
99 int time = value % 65536;
100
101 return new DateTime(1980 + (date / 512), (date % 512) / 32, date % 32, time / 2048, (time % 2048) / 32, (time % 32) * 2);
102 }
103
104 /// <summary>
105 /// Gets the element corresponding to the row it came from.
106 /// </summary>
107 /// <param name="row">The row corresponding to the element.</param>
108 /// <returns>The indexed element.</returns>
109 public Wix.ISchemaElement GetIndexedElement(Row row)
110 {
111 return this.GetIndexedElement(row.TableDefinition.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter));
112 }
113
114 /// <summary>
115 /// Gets the element corresponding to the primary key of the given table.
116 /// </summary>
117 /// <param name="table">The table corresponding to the element.</param>
118 /// <param name="primaryKey">The primary key corresponding to the element.</param>
119 /// <returns>The indexed element.</returns>
120 public Wix.ISchemaElement GetIndexedElement(string table, params string[] primaryKey)
121 {
122 return (Wix.ISchemaElement)this.elements[String.Concat(table, ':', String.Join(DecompilerConstants.PrimaryKeyDelimiterString, primaryKey))];
123 }
124
125 /// <summary>
126 /// Index an element by its corresponding row.
127 /// </summary>
128 /// <param name="row">The row corresponding to the element.</param>
129 /// <param name="element">The element to index.</param>
130 public void IndexElement(Row row, Wix.ISchemaElement element)
131 {
132 this.elements.Add(String.Concat(row.TableDefinition.Name, ':', row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter)), element);
133 }
134
135 /// <summary>
136 /// Indicates the decompiler encountered and unexpected table to decompile.
137 /// </summary>
138 /// <param name="table">Unknown decompiled table.</param>
139 public void UnexpectedTable(Table table)
140 {
141 this.OnMessage(WixErrors.TableDecompilationUnimplemented(table.Name));
142 }
143
144 /// <summary>
145 /// Sends a message to the message delegate if there is one.
146 /// </summary>
147 /// <param name="mea">Message event arguments.</param>
148 public void OnMessage(MessageEventArgs e)
149 {
150 Messaging.Instance.OnMessage(e);
151 }
152 }
153#endif
154}