diff options
Diffstat (limited to 'src/ext/Dependency/wixext/DependencyCompiler.cs')
-rw-r--r-- | src/ext/Dependency/wixext/DependencyCompiler.cs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/ext/Dependency/wixext/DependencyCompiler.cs b/src/ext/Dependency/wixext/DependencyCompiler.cs new file mode 100644 index 00000000..3d6c84a7 --- /dev/null +++ b/src/ext/Dependency/wixext/DependencyCompiler.cs | |||
@@ -0,0 +1,61 @@ | |||
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.Dependency | ||
4 | { | ||
5 | using System.Collections.Generic; | ||
6 | using System.Xml.Linq; | ||
7 | using WixToolset.Data; | ||
8 | using WixToolset.Extensibility; | ||
9 | using WixToolset.Extensibility.Data; | ||
10 | |||
11 | /// <summary> | ||
12 | /// The compiler for the WiX Toolset Dependency Extension. | ||
13 | /// </summary> | ||
14 | public sealed class DependencyCompiler : BaseCompilerExtension | ||
15 | { | ||
16 | public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/dependency"; | ||
17 | |||
18 | /// <summary> | ||
19 | /// Processes an attribute for the Compiler. | ||
20 | /// </summary> | ||
21 | /// <param name="sourceLineNumbers">Source line number for the parent element.</param> | ||
22 | /// <param name="parentElement">Parent element of attribute.</param> | ||
23 | /// <param name="attribute">Attribute to process.</param> | ||
24 | public override void ParseAttribute(Intermediate intermediate, IntermediateSection section, XElement parentElement, XAttribute attribute, IDictionary<string, string> context) | ||
25 | { | ||
26 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(parentElement); | ||
27 | var addCheck = YesNoType.NotSet; | ||
28 | var addRequire = YesNoType.NotSet; | ||
29 | |||
30 | switch (parentElement.Name.LocalName) | ||
31 | { | ||
32 | case "Provides": | ||
33 | if (attribute.Name.LocalName == "Check" && parentElement.Parent?.Name.LocalName == "Component") | ||
34 | { | ||
35 | addCheck = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attribute); | ||
36 | } | ||
37 | break; | ||
38 | case "Requires": | ||
39 | case "RequiresRef": | ||
40 | if (attribute.Name.LocalName == "Enforce" && parentElement.Parent?.Parent?.Name.LocalName == "Component") | ||
41 | { | ||
42 | addRequire = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attribute); | ||
43 | } | ||
44 | break; | ||
45 | } | ||
46 | |||
47 | if (addCheck == YesNoType.NotSet && addRequire == YesNoType.NotSet) | ||
48 | { | ||
49 | this.ParseHelper.UnexpectedAttribute(parentElement, attribute); | ||
50 | } | ||
51 | else if (addCheck == YesNoType.Yes) | ||
52 | { | ||
53 | this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4DependencyCheck", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); | ||
54 | } | ||
55 | else if (addRequire == YesNoType.Yes) | ||
56 | { | ||
57 | this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4DependencyRequire", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | } | ||