blob: 855ce9a9b07b961e62096f88602aa53fa06c8bd0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// 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.Mba.Core
{
using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.XPath;
/// <summary>
/// Default implementation of <see cref="IOverridableVariables"/>.
/// </summary>
public class OverridableVariablesInfo : IOverridableVariables
{
/// <inheritdoc />
public IDictionary<string, IOverridableVariableInfo> Variables { get; internal set; }
internal OverridableVariablesInfo() { }
/// <summary>
/// Parses the overridable variable info from the BA manifest.
/// </summary>
/// <param name="root">XML root</param>
/// <returns>The parsed information.</returns>
public static IOverridableVariables ParseFromXml(XPathNavigator root)
{
XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable);
namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace);
XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixStdbaOverridableVariable", namespaceManager);
var overridableVariables = new OverridableVariablesInfo();
overridableVariables.Variables = new Dictionary<string, IOverridableVariableInfo>();
foreach (XPathNavigator node in nodes)
{
var variable = new OverridableVariableInfo();
string name = BootstrapperApplicationData.GetAttribute(node, "Name");
if (name == null)
{
throw new Exception("Failed to get name for overridable variable.");
}
variable.Name = name;
overridableVariables.Variables.Add(variable.Name, variable);
}
return overridableVariables;
}
}
}
|