diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-11-14 23:08:24 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-11-14 23:08:24 -0800 |
| commit | 404f34f00ecce034a8a06fe4757789c6ce62f3f6 (patch) | |
| tree | 7132435cfa13f0f9b0e872a57ab19d52a12bb103 /src/WixToolset.Extensibility/BaseCompilerExtension.cs | |
| parent | 3f6e936c5e9d7a9df7e3e0ed1bc17001c53db5b3 (diff) | |
| download | wix-404f34f00ecce034a8a06fe4757789c6ce62f3f6.tar.gz wix-404f34f00ecce034a8a06fe4757789c6ce62f3f6.tar.bz2 wix-404f34f00ecce034a8a06fe4757789c6ce62f3f6.zip | |
Remove ICompilerCore, introduce IParseHelper and other small fixes
Diffstat (limited to 'src/WixToolset.Extensibility/BaseCompilerExtension.cs')
| -rw-r--r-- | src/WixToolset.Extensibility/BaseCompilerExtension.cs | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/WixToolset.Extensibility/BaseCompilerExtension.cs b/src/WixToolset.Extensibility/BaseCompilerExtension.cs new file mode 100644 index 00000000..508886d3 --- /dev/null +++ b/src/WixToolset.Extensibility/BaseCompilerExtension.cs | |||
| @@ -0,0 +1,76 @@ | |||
| 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.Extensibility | ||
| 4 | { | ||
| 5 | using System.Collections.Generic; | ||
| 6 | using System.Xml.Linq; | ||
| 7 | using WixToolset.Data; | ||
| 8 | using WixToolset.Extensibility.Services; | ||
| 9 | |||
| 10 | /// <summary> | ||
| 11 | /// Base class for creating a compiler extension. | ||
| 12 | /// </summary> | ||
| 13 | public abstract class BaseCompilerExtension : ICompilerExtension | ||
| 14 | { | ||
| 15 | /// <summary> | ||
| 16 | /// ParserHelper for use by the extension. | ||
| 17 | /// </summary> | ||
| 18 | protected IParseHelper ParseHelper { get; private set; } | ||
| 19 | |||
| 20 | /// <summary> | ||
| 21 | /// Gets the schema namespace for this extension. | ||
| 22 | /// </summary> | ||
| 23 | /// <value>Schema namespace supported by this extension.</value> | ||
| 24 | public XNamespace Namespace { get; protected set; } | ||
| 25 | |||
| 26 | /// <summary> | ||
| 27 | /// Called at the beginning of the compilation of a source file. | ||
| 28 | /// </summary> | ||
| 29 | public virtual void PreCompile(ICompileContext context) | ||
| 30 | { | ||
| 31 | this.ParseHelper = context.ServiceProvider.GetService<IParseHelper>(); | ||
| 32 | } | ||
| 33 | |||
| 34 | /// <summary> | ||
| 35 | /// Processes an attribute for the Compiler. | ||
| 36 | /// </summary> | ||
| 37 | /// <param name="parentElement">Parent element of attribute.</param> | ||
| 38 | /// <param name="attribute">Attribute to process.</param> | ||
| 39 | /// <param name="context">Extra information about the context in which this element is being parsed.</param> | ||
| 40 | public virtual void ParseAttribute(Intermediate intermediate, IntermediateSection section, XElement parentElement, XAttribute attribute, IDictionary<string, string> context) | ||
| 41 | { | ||
| 42 | this.ParseHelper.UnexpectedAttribute(parentElement, attribute); | ||
| 43 | } | ||
| 44 | |||
| 45 | /// <summary> | ||
| 46 | /// Processes an element for the Compiler. | ||
| 47 | /// </summary> | ||
| 48 | /// <param name="parentElement">Parent element of element to process.</param> | ||
| 49 | /// <param name="element">Element to process.</param> | ||
| 50 | /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param> | ||
| 51 | public virtual void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context) | ||
| 52 | { | ||
| 53 | this.ParseHelper.UnexpectedElement(parentElement, element); | ||
| 54 | } | ||
| 55 | |||
| 56 | /// <summary> | ||
| 57 | /// Processes an element for the Compiler, with the ability to supply a component keypath. | ||
| 58 | /// </summary> | ||
| 59 | /// <param name="parentElement">Parent element of element to process.</param> | ||
| 60 | /// <param name="element">Element to process.</param> | ||
| 61 | /// <param name="keyPath">Explicit key path.</param> | ||
| 62 | /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param> | ||
| 63 | public virtual ComponentKeyPath ParsePossibleKeyPathElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context) | ||
| 64 | { | ||
| 65 | this.ParseElement(intermediate, section, parentElement, element, context); | ||
| 66 | return null; | ||
| 67 | } | ||
| 68 | |||
| 69 | /// <summary> | ||
| 70 | /// Called at the end of the compilation of a source file. | ||
| 71 | /// </summary> | ||
| 72 | public virtual void PostCompile(Intermediate intermediate) | ||
| 73 | { | ||
| 74 | } | ||
| 75 | } | ||
| 76 | } | ||
