1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
// 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.UI
{
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using WixToolset.Data;
using WixToolset.Data.Symbols;
using WixToolset.Extensibility;
/// <summary>
/// The decompiler for the WiX Toolset UI Extension.
/// </summary>
public sealed class UICompiler : BaseCompilerExtension
{
public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/ui";
/// <summary>
/// Processes an element for the Compiler.
/// </summary>
/// <param name="sourceLineNumbers">Source line number for the parent element.</param>
/// <param name="parentElement">Parent element of element to process.</param>
/// <param name="element">Element to process.</param>
/// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context)
{
switch (parentElement.Name.LocalName)
{
case "Fragment":
case "Module":
case "PatchFamily":
case "Package":
case "UI":
switch (element.Name.LocalName)
{
case "WixUI":
this.ParseWixUIElement(intermediate, section, element);
break;
default:
this.ParseHelper.UnexpectedElement(parentElement, element);
break;
}
break;
default:
this.ParseHelper.UnexpectedElement(parentElement, element);
break;
}
}
/// <summary>
/// Parses a WixUI element.
/// </summary>
private void ParseWixUIElement(Intermediate intermediate, IntermediateSection section, XElement element)
{
var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
string id = null;
string installDirectory = null;
YesNoType extendedPathValidation = YesNoType.No;
foreach (var attrib in element.Attributes())
{
if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
{
switch (attrib.Name.LocalName)
{
case "Id":
id = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
break;
case "InstallDirectory":
installDirectory = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
break;
case "ExtendedPathValidation":
extendedPathValidation = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib);
break;
default:
this.ParseHelper.UnexpectedAttribute(element, attrib);
break;
}
}
else
{
this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib);
}
}
if (null == id)
{
this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id"));
}
else
{
var platform = this.Context.Platform == Platform.ARM64 ? "A64" : this.Context.Platform.ToString();
if (extendedPathValidation == YesNoType.No)
{
this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixUI, $"{id}_{platform}");
}
else
{
this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixUI, $"{id}_ExtendedPathValidation_{platform}");
}
if (installDirectory != null)
{
section.AddSymbol(new PropertySymbol(sourceLineNumbers, new Identifier(AccessModifier.Global, "WIXUI_INSTALLDIR"))
{
Value = installDirectory
});
}
}
this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
}
}
}
|