aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Extensibility/CompilerExtension.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Extensibility/CompilerExtension.cs')
-rw-r--r--src/WixToolset.Extensibility/CompilerExtension.cs74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/WixToolset.Extensibility/CompilerExtension.cs b/src/WixToolset.Extensibility/CompilerExtension.cs
new file mode 100644
index 00000000..522ffcf8
--- /dev/null
+++ b/src/WixToolset.Extensibility/CompilerExtension.cs
@@ -0,0 +1,74 @@
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 WixToolset.Extensibility
4{
5 using System.Collections.Generic;
6 using System.Xml.Linq;
7
8 /// <summary>
9 /// Base class for creating a compiler extension.
10 /// </summary>
11 public abstract class CompilerExtension : ICompilerExtension
12 {
13 /// <summary>
14 /// Gets or sets the compiler core for the extension.
15 /// </summary>
16 /// <value>Compiler core for the extension.</value>
17 public ICompilerCore Core { get; set; }
18
19 /// <summary>
20 /// Gets the schema namespace for this extension.
21 /// </summary>
22 /// <value>Schema namespace supported by this extension.</value>
23 public XNamespace Namespace { get; protected set; }
24
25 /// <summary>
26 /// Called at the beginning of the compilation of a source file.
27 /// </summary>
28 public virtual void Initialize()
29 {
30 }
31
32 /// <summary>
33 /// Processes an attribute for the Compiler.
34 /// </summary>
35 /// <param name="parentElement">Parent element of attribute.</param>
36 /// <param name="attribute">Attribute to process.</param>
37 /// <param name="context">Extra information about the context in which this element is being parsed.</param>
38 public virtual void ParseAttribute(XElement parentElement, XAttribute attribute, IDictionary<string, string> context)
39 {
40 this.Core.UnexpectedAttribute(parentElement, attribute);
41 }
42
43 /// <summary>
44 /// Processes an element for the Compiler.
45 /// </summary>
46 /// <param name="parentElement">Parent element of element to process.</param>
47 /// <param name="element">Element to process.</param>
48 /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
49 public virtual void ParseElement(XElement parentElement, XElement element, IDictionary<string, string> context)
50 {
51 this.Core.UnexpectedElement(parentElement, element);
52 }
53
54 /// <summary>
55 /// Processes an element for the Compiler, with the ability to supply a component keypath.
56 /// </summary>
57 /// <param name="parentElement">Parent element of element to process.</param>
58 /// <param name="element">Element to process.</param>
59 /// <param name="keyPath">Explicit key path.</param>
60 /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
61 public virtual ComponentKeyPath ParsePossibleKeyPathElement(XElement parentElement, XElement element, IDictionary<string, string> context)
62 {
63 this.ParseElement(parentElement, element, context);
64 return null;
65 }
66
67 /// <summary>
68 /// Called at the end of the compilation of a source file.
69 /// </summary>
70 public virtual void Finish()
71 {
72 }
73 }
74}