diff options
Diffstat (limited to '')
-rw-r--r-- | src/WixToolset.Mba.Core/BootstrapperApplicationData.cs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs new file mode 100644 index 00000000..a17f1a05 --- /dev/null +++ b/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs | |||
@@ -0,0 +1,63 @@ | |||
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.BootstrapperCore | ||
4 | { | ||
5 | using System; | ||
6 | using System.IO; | ||
7 | using System.Xml.XPath; | ||
8 | |||
9 | public class BootstrapperApplicationData : IBootstrapperApplicationData | ||
10 | { | ||
11 | public const string DefaultFileName = "BootstrapperApplicationData.xml"; | ||
12 | public const string XMLNamespace = "http://wixtoolset.org/schemas/v4/2010/BootstrapperApplicationData"; | ||
13 | |||
14 | public static readonly DirectoryInfo DefaultFolder; | ||
15 | public static readonly FileInfo DefaultFile; | ||
16 | |||
17 | static BootstrapperApplicationData() | ||
18 | { | ||
19 | DefaultFolder = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); | ||
20 | DefaultFile = new FileInfo(Path.Combine(DefaultFolder.FullName, DefaultFileName)); | ||
21 | } | ||
22 | |||
23 | public FileInfo BADataFile { get; private set; } | ||
24 | |||
25 | public IBundleInfo Bundle { get; private set; } | ||
26 | |||
27 | public BootstrapperApplicationData() : this(DefaultFile) { } | ||
28 | |||
29 | public BootstrapperApplicationData(FileInfo baDataFile) | ||
30 | { | ||
31 | this.BADataFile = baDataFile; | ||
32 | |||
33 | using (FileStream fs = this.BADataFile.OpenRead()) | ||
34 | { | ||
35 | this.Bundle = BundleInfo.ParseBundleFromStream(fs); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | public static string GetAttribute(XPathNavigator node, string attributeName) | ||
40 | { | ||
41 | XPathNavigator attribute = node.SelectSingleNode("@" + attributeName); | ||
42 | |||
43 | if (attribute == null) | ||
44 | { | ||
45 | return null; | ||
46 | } | ||
47 | |||
48 | return attribute.Value; | ||
49 | } | ||
50 | |||
51 | public static bool? GetYesNoAttribute(XPathNavigator node, string attributeName) | ||
52 | { | ||
53 | string attributeValue = GetAttribute(node, attributeName); | ||
54 | |||
55 | if (attributeValue == null) | ||
56 | { | ||
57 | return null; | ||
58 | } | ||
59 | |||
60 | return attributeValue.Equals("yes", StringComparison.InvariantCulture); | ||
61 | } | ||
62 | } | ||
63 | } | ||