| 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.Services |
| 4 | { |
| 5 | using System.Xml.Linq; |
| 6 | using WixToolset.Extensibility.Data; |
| 7 | |
| 8 | /// <summary> |
| 9 | /// Interface provided to help preprocessor extensions. |
| 10 | /// </summary> |
| 11 | public interface IPreprocessHelper |
| 12 | { |
| 13 | /// <summary> |
| 14 | /// Add a variable. |
| 15 | /// </summary> |
| 16 | /// <param name="context">The preprocess context.</param> |
| 17 | /// <param name="name">The variable name.</param> |
| 18 | /// <param name="value">The variable value.</param> |
| 19 | void AddVariable(IPreprocessContext context, string name, string value); |
| 20 | |
| 21 | /// <summary> |
| 22 | /// Add a variable. |
| 23 | /// </summary> |
| 24 | /// <param name="context">The preprocess context.</param> |
| 25 | /// <param name="name">The variable name.</param> |
| 26 | /// <param name="value">The variable value.</param> |
| 27 | /// <param name="showWarning">Set to true to show variable overwrite warning.</param> |
| 28 | void AddVariable(IPreprocessContext context, string name, string value, bool showWarning); |
| 29 | |
| 30 | /// <summary> |
| 31 | /// Evaluate a function. |
| 32 | /// </summary> |
| 33 | /// <param name="context">The preprocess context.</param> |
| 34 | /// <param name="function">The function expression including the prefix and name.</param> |
| 35 | /// <returns>The function value.</returns> |
| 36 | string EvaluateFunction(IPreprocessContext context, string function); |
| 37 | |
| 38 | /// <summary> |
| 39 | /// Evaluate a function. |
| 40 | /// </summary> |
| 41 | /// <param name="context">The preprocess context.</param> |
| 42 | /// <param name="prefix">The function prefix.</param> |
| 43 | /// <param name="function">The function name.</param> |
| 44 | /// <param name="args">The arguments for the function.</param> |
| 45 | /// <returns>The function value or null if the function is not defined.</returns> |
| 46 | string EvaluateFunction(IPreprocessContext context, string prefix, string function, string[] args); |
| 47 | |
| 48 | /// <summary> |
| 49 | /// Get the value of a variable expression like var.name. |
| 50 | /// </summary> |
| 51 | /// <param name="context">The preprocess context.</param> |
| 52 | /// <param name="variable">The variable expression including the optional prefix and name.</param> |
| 53 | /// <param name="allowMissingPrefix">true to allow the variable prefix to be missing.</param> |
| 54 | /// <returns>The variable value.</returns> |
| 55 | string GetVariableValue(IPreprocessContext context, string variable, bool allowMissingPrefix); |
| 56 | |
| 57 | /// <summary> |
| 58 | /// Get the value of a variable. |
| 59 | /// </summary> |
| 60 | /// <param name="context">The preprocess context.</param> |
| 61 | /// <param name="prefix">The variable prefix.</param> |
| 62 | /// <param name="name">The variable name.</param> |
| 63 | /// <returns>The variable value or null if the variable is not set.</returns> |
| 64 | string GetVariableValue(IPreprocessContext context, string prefix, string name); |
| 65 | |
| 66 | /// <summary> |
| 67 | /// Evaluate a Pragma. |
| 68 | /// </summary> |
| 69 | /// <param name="context">The preprocess context.</param> |
| 70 | /// <param name="pragmaName">The pragma's full name (<prefix>.<pragma>).</param> |
| 71 | /// <param name="args">The arguments to the pragma.</param> |
| 72 | /// <param name="parent">The parent element of the pragma.</param> |
| 73 | void PreprocessPragma(IPreprocessContext context, string pragmaName, string args, XContainer parent); |
| 74 | |
| 75 | /// <summary> |
| 76 | /// Replaces parameters in the source text. |
| 77 | /// </summary> |
| 78 | /// <param name="context">The preprocess context.</param> |
| 79 | /// <param name="value">Text that may contain parameters to replace.</param> |
| 80 | /// <returns>Text after parameters have been replaced.</returns> |
| 81 | string PreprocessString(IPreprocessContext context, string value); |
| 82 | |
| 83 | /// <summary> |
| 84 | /// Remove a variable. |
| 85 | /// </summary> |
| 86 | /// <param name="context">The preprocess context.</param> |
| 87 | /// <param name="name">The variable name.</param> |
| 88 | void RemoveVariable(IPreprocessContext context, string name); |
| 89 | } |
| 90 | } |