// 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 WixToolset.Extensibility { using System.Xml.Linq; using WixToolset.Data; /// /// Base class for creating a preprocessor extension. /// public abstract class PreprocessorExtension : IPreprocessorExtension { /// /// Gets or sets the preprocessor core for the extension. /// /// Preprocessor core for the extension. public IPreprocessorCore Core { get; set; } /// /// Gets or sets the variable prefixes for the extension. /// /// The variable prefixes for the extension. public virtual string[] Prefixes { get { return null; } } /// /// Called at the beginning of the preprocessing of a source file. /// public virtual void Initialize() { } /// /// Gets the value of a variable whose prefix matches the extension. /// /// The prefix of the variable to be processed by the extension. /// The name of the variable. /// The value of the variable or null if the variable is undefined. public virtual string GetVariableValue(string prefix, string name) { return null; } /// /// Evaluates a function defined in the extension. /// /// The prefix of the function to be processed by the extension. /// The name of the function. /// The list of arguments. /// The value of the function or null if the function is not defined. public virtual string EvaluateFunction(string prefix, string function, string[] args) { return null; } /// /// Processes a pragma defined in the extension. /// /// The location of this pragma's PI. /// The prefix of the pragma to be processed by the extension. /// The name of the pragma. /// The pragma's arguments. /// The parent node of the pragma. /// false if the pragma is not defined. /// Don't return false for any condition except for unrecognized pragmas. Throw errors that are fatal to the compile. use core.OnMessage for warnings and messages. public virtual bool ProcessPragma(SourceLineNumber sourceLineNumbers, string prefix, string pragma, string args, XContainer parent) { return false; } /// /// Preprocess a document after normal preprocessing has completed. /// /// The document to preprocess. public virtual void PreprocessDocument(XDocument document) { } /// /// Preprocesses a parameter. /// /// Name of parameter that matches extension. /// The value of the parameter after processing. /// By default this method will cause an error if its called. public virtual string PreprocessParameter(string name) { return null; } /// /// Called at the end of the preprocessing of a source file. /// public virtual void Finish() { } } }