diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-06-29 19:14:02 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-07-02 12:50:09 -0500 |
| commit | 8cbfc326cccf8d9b3b63cb6f752fc770f7dee0fc (patch) | |
| tree | 639f70e7327cdfade62271da04aaaaae2e85cc05 /src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs | |
| parent | e844f12f7d7247a1e9ba4eef2a388e614001bb24 (diff) | |
| download | wix-8cbfc326cccf8d9b3b63cb6f752fc770f7dee0fc.tar.gz wix-8cbfc326cccf8d9b3b63cb6f752fc770f7dee0fc.tar.bz2 wix-8cbfc326cccf8d9b3b63cb6f752fc770f7dee0fc.zip | |
Expose overridable variable APIs in balutil and Mba.Core.
Fixes #4777
Diffstat (limited to 'src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs')
| -rw-r--r-- | src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs b/src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs new file mode 100644 index 00000000..855ce9a9 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs | |||
| @@ -0,0 +1,51 @@ | |||
| 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.Mba.Core | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.Xml; | ||
| 8 | using System.Xml.XPath; | ||
| 9 | |||
| 10 | /// <summary> | ||
| 11 | /// Default implementation of <see cref="IOverridableVariables"/>. | ||
| 12 | /// </summary> | ||
| 13 | public class OverridableVariablesInfo : IOverridableVariables | ||
| 14 | { | ||
| 15 | /// <inheritdoc /> | ||
| 16 | public IDictionary<string, IOverridableVariableInfo> Variables { get; internal set; } | ||
| 17 | |||
| 18 | internal OverridableVariablesInfo() { } | ||
| 19 | |||
| 20 | /// <summary> | ||
| 21 | /// Parses the overridable variable info from the BA manifest. | ||
| 22 | /// </summary> | ||
| 23 | /// <param name="root">XML root</param> | ||
| 24 | /// <returns>The parsed information.</returns> | ||
| 25 | public static IOverridableVariables ParseFromXml(XPathNavigator root) | ||
| 26 | { | ||
| 27 | XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); | ||
| 28 | namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); | ||
| 29 | XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixStdbaOverridableVariable", namespaceManager); | ||
| 30 | |||
| 31 | var overridableVariables = new OverridableVariablesInfo(); | ||
| 32 | overridableVariables.Variables = new Dictionary<string, IOverridableVariableInfo>(); | ||
| 33 | |||
| 34 | foreach (XPathNavigator node in nodes) | ||
| 35 | { | ||
| 36 | var variable = new OverridableVariableInfo(); | ||
| 37 | |||
| 38 | string name = BootstrapperApplicationData.GetAttribute(node, "Name"); | ||
| 39 | if (name == null) | ||
| 40 | { | ||
| 41 | throw new Exception("Failed to get name for overridable variable."); | ||
| 42 | } | ||
| 43 | variable.Name = name; | ||
| 44 | |||
| 45 | overridableVariables.Variables.Add(variable.Name, variable); | ||
| 46 | } | ||
| 47 | |||
| 48 | return overridableVariables; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | } | ||
