aboutsummaryrefslogtreecommitdiff
path: root/src/test/Example.Extension/ExampleCompilerExtension.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/Example.Extension/ExampleCompilerExtension.cs')
-rw-r--r--src/test/Example.Extension/ExampleCompilerExtension.cs195
1 files changed, 0 insertions, 195 deletions
diff --git a/src/test/Example.Extension/ExampleCompilerExtension.cs b/src/test/Example.Extension/ExampleCompilerExtension.cs
deleted file mode 100644
index 5b8d4b3f..00000000
--- a/src/test/Example.Extension/ExampleCompilerExtension.cs
+++ /dev/null
@@ -1,195 +0,0 @@
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 Example.Extension
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Xml.Linq;
8 using WixToolset.Data;
9 using WixToolset.Extensibility;
10
11 internal class ExampleCompilerExtension : BaseCompilerExtension
12 {
13 public override XNamespace Namespace => "http://www.example.com/scheams/v1/wxs";
14 public string BundleExtensionId => "ExampleBundleExtension";
15
16 public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context)
17 {
18 var processed = false;
19
20 switch (parentElement.Name.LocalName)
21 {
22 case "Bundle":
23 case "Fragment":
24 switch (element.Name.LocalName)
25 {
26 case "ExampleEnsureTable":
27 this.ParseExampleEnsureTableElement(intermediate, section, element);
28 processed = true;
29 break;
30 case "ExampleSearch":
31 this.ParseExampleSearchElement(intermediate, section, element);
32 processed = true;
33 break;
34 case "ExampleSearchRef":
35 this.ParseExampleSearchRefElement(intermediate, section, element);
36 processed = true;
37 break;
38 }
39 break;
40 case "Component":
41 switch (element.Name.LocalName)
42 {
43 case "Example":
44 this.ParseExampleElement(intermediate, section, element);
45 processed = true;
46 break;
47 }
48 break;
49 }
50
51 if (!processed)
52 {
53 base.ParseElement(intermediate, section, parentElement, element, context);
54 }
55 }
56
57 private void ParseExampleElement(Intermediate intermediate, IntermediateSection section, XElement element)
58 {
59 var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
60 Identifier id = null;
61 string value = null;
62
63 foreach (var attrib in element.Attributes())
64 {
65 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
66 {
67 switch (attrib.Name.LocalName)
68 {
69 case "Id":
70 id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib);
71 break;
72
73 case "Value":
74 value = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
75 break;
76
77 default:
78 this.ParseHelper.UnexpectedAttribute(element, attrib);
79 break;
80 }
81 }
82 else
83 {
84 this.ParseAttribute(intermediate, section, element, attrib, null);
85 }
86 }
87
88 if (null == id)
89 {
90 //this.Messaging(WixErrors.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id"));
91 }
92
93 if (!this.Messaging.EncounteredError)
94 {
95 var symbol = this.ParseHelper.CreateSymbol(section, sourceLineNumbers, "Example", id);
96 symbol.Set(0, value);
97 }
98 }
99
100 private void ParseExampleEnsureTableElement(Intermediate intermediate, IntermediateSection section, XElement element)
101 {
102 var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
103 this.ParseHelper.EnsureTable(section, sourceLineNumbers, ExampleTableDefinitions.NotInAll);
104 }
105
106 private void ParseExampleSearchElement(Intermediate intermediate, IntermediateSection section, XElement element)
107 {
108 var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
109 Identifier id = null;
110 string searchFor = null;
111 string variable = null;
112 string condition = null;
113 string after = null;
114
115 foreach (var attrib in element.Attributes())
116 {
117 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
118 {
119 switch (attrib.Name.LocalName)
120 {
121 case "Id":
122 id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib);
123 break;
124 case "Variable":
125 variable = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
126 break;
127 case "Condition":
128 condition = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
129 break;
130 case "After":
131 after = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
132 break;
133 case "SearchFor":
134 searchFor = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
135 break;
136
137 default:
138 this.ParseHelper.UnexpectedAttribute(element, attrib);
139 break;
140 }
141 }
142 else
143 {
144 this.ParseAttribute(intermediate, section, element, attrib, null);
145 }
146 }
147
148 if (null == id)
149 {
150 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id"));
151 }
152
153 if (!this.Messaging.EncounteredError)
154 {
155 this.ParseHelper.CreateWixSearchSymbol(section, sourceLineNumbers, element.Name.LocalName, id, variable, condition, after, this.BundleExtensionId);
156 }
157
158 if (!this.Messaging.EncounteredError)
159 {
160 var symbol = section.AddSymbol(new ExampleSearchSymbol(sourceLineNumbers, id)
161 {
162 SearchFor = searchFor,
163 });
164 }
165 }
166
167 private void ParseExampleSearchRefElement(Intermediate intermediate, IntermediateSection section, XElement element)
168 {
169 var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
170
171 foreach (var attrib in element.Attributes())
172 {
173 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
174 {
175 switch (attrib.Name.LocalName)
176 {
177 case "Id":
178 var refId = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
179 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, ExampleSymbolDefinitions.ExampleSearch, refId);
180 break;
181 default:
182 this.ParseHelper.UnexpectedAttribute(element, attrib);
183 break;
184 }
185 }
186 else
187 {
188 this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib);
189 }
190 }
191
192 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
193 }
194 }
195}