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
|
// 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 Example.Extension
{
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using WixToolset.Data;
using WixToolset.Extensibility;
internal class ExampleCompilerExtension : BaseCompilerExtension
{
public ExampleCompilerExtension()
{
this.Namespace = "http://www.example.com/scheams/v1/wxs";
}
public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context)
{
var processed = false;
switch (parentElement.Name.LocalName)
{
case "Component":
switch (element.Name.LocalName)
{
case "Example":
this.ParseExampleElement(intermediate, section, element);
processed = true;
break;
}
break;
}
if (!processed)
{
base.ParseElement(intermediate, section, parentElement, element, context);
}
}
private void ParseExampleElement(Intermediate intermediate, IntermediateSection section, XElement element)
{
var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
Identifier id = null;
string value = null;
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.GetAttributeIdentifier(sourceLineNumbers, attrib);
break;
case "Value":
value = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
break;
default:
this.ParseHelper.UnexpectedAttribute(element, attrib);
break;
}
}
else
{
this.ParseAttribute(intermediate, section, element, attrib, null);
}
}
if (null == id)
{
//this.Messaging(WixErrors.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id"));
}
if (!this.Messaging.EncounteredError)
{
var tuple = this.ParseHelper.CreateRow(section, sourceLineNumbers, "Example", id);
tuple.Set(1, value);
}
}
}
}
|