diff options
author | Rob Mensching <rob@firegiant.com> | 2017-12-06 11:39:26 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2017-12-06 11:40:03 -0800 |
commit | 5ba862bfa618c89a563d555e8ce7b44a904df406 (patch) | |
tree | cc2655422be3eec1f200efcbc0e562349c229274 /src/test/Example.Extension/ExampleCompilerExtension.cs | |
parent | e53afb01c6e01bb9e6521fa77d31e575abc73f9c (diff) | |
download | wix-5ba862bfa618c89a563d555e8ce7b44a904df406.tar.gz wix-5ba862bfa618c89a563d555e8ce7b44a904df406.tar.bz2 wix-5ba862bfa618c89a563d555e8ce7b44a904df406.zip |
Add support for loading Intermediates from extensions
Diffstat (limited to 'src/test/Example.Extension/ExampleCompilerExtension.cs')
-rw-r--r-- | src/test/Example.Extension/ExampleCompilerExtension.cs | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/src/test/Example.Extension/ExampleCompilerExtension.cs b/src/test/Example.Extension/ExampleCompilerExtension.cs deleted file mode 100644 index 5b20e48f..00000000 --- a/src/test/Example.Extension/ExampleCompilerExtension.cs +++ /dev/null | |||
@@ -1,84 +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 | |||
3 | namespace 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 ExampleCompilerExtension() | ||
14 | { | ||
15 | this.Namespace = "http://www.example.com/scheams/v1/wxs"; | ||
16 | } | ||
17 | |||
18 | public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context) | ||
19 | { | ||
20 | var processed = false; | ||
21 | |||
22 | switch (parentElement.Name.LocalName) | ||
23 | { | ||
24 | case "Component": | ||
25 | switch (element.Name.LocalName) | ||
26 | { | ||
27 | case "Example": | ||
28 | this.ParseExampleElement(intermediate, section, element); | ||
29 | processed = true; | ||
30 | break; | ||
31 | } | ||
32 | break; | ||
33 | } | ||
34 | |||
35 | if (!processed) | ||
36 | { | ||
37 | base.ParseElement(intermediate, section, parentElement, element, context); | ||
38 | } | ||
39 | } | ||
40 | |||
41 | private void ParseExampleElement(Intermediate intermediate, IntermediateSection section, XElement element) | ||
42 | { | ||
43 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); | ||
44 | Identifier id = null; | ||
45 | string value = null; | ||
46 | |||
47 | foreach (var attrib in element.Attributes()) | ||
48 | { | ||
49 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | ||
50 | { | ||
51 | switch (attrib.Name.LocalName) | ||
52 | { | ||
53 | case "Id": | ||
54 | id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); | ||
55 | break; | ||
56 | |||
57 | case "Value": | ||
58 | value = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
59 | break; | ||
60 | |||
61 | default: | ||
62 | this.ParseHelper.UnexpectedAttribute(element, attrib); | ||
63 | break; | ||
64 | } | ||
65 | } | ||
66 | else | ||
67 | { | ||
68 | this.ParseAttribute(intermediate, section, element, attrib, null); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | if (null == id) | ||
73 | { | ||
74 | //this.Messaging(WixErrors.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); | ||
75 | } | ||
76 | |||
77 | if (!this.Messaging.EncounteredError) | ||
78 | { | ||
79 | var tuple = this.ParseHelper.CreateRow(section, sourceLineNumbers, "Example", id); | ||
80 | tuple.Set(1, value); | ||
81 | } | ||
82 | } | ||
83 | } | ||
84 | } | ||