From 3d2d46f62fc01e2653d0251ad9703090574e7c41 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 6 Mar 2024 14:48:10 -0800 Subject: Better .nupkg names --- .../BootstrapperApplicationData.cs | 101 +++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/api/burn/WixToolset.BootstrapperApplicationApi/BootstrapperApplicationData.cs (limited to 'src/api/burn/WixToolset.BootstrapperApplicationApi/BootstrapperApplicationData.cs') diff --git a/src/api/burn/WixToolset.BootstrapperApplicationApi/BootstrapperApplicationData.cs b/src/api/burn/WixToolset.BootstrapperApplicationApi/BootstrapperApplicationData.cs new file mode 100644 index 00000000..10cb863f --- /dev/null +++ b/src/api/burn/WixToolset.BootstrapperApplicationApi/BootstrapperApplicationData.cs @@ -0,0 +1,101 @@ +// 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.BootstrapperApplicationApi +{ + using System; + using System.IO; + using System.Xml.XPath; + + /// + /// Utility class for reading BootstrapperApplicationData.xml. + /// + public class BootstrapperApplicationData : IBootstrapperApplicationData + { + /// + /// The default file name for BootstrapperApplicationData. + /// + public const string DefaultFileName = "BootstrapperApplicationData.xml"; + + /// + /// The XML namespace for BootstrapperApplicationData. + /// + public const string XMLNamespace = "http://wixtoolset.org/schemas/v4/BootstrapperApplicationData"; + + /// + /// The default path of where the BA was extracted to. + /// + public static readonly DirectoryInfo DefaultFolder; + + /// + /// The default path to BootstrapperApplicationData.xml. + /// + public static readonly FileInfo DefaultFile; + + static BootstrapperApplicationData() + { + DefaultFolder = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); + DefaultFile = new FileInfo(Path.Combine(DefaultFolder.FullName, DefaultFileName)); + } + + /// + public FileInfo BADataFile { get; private set; } + + /// + public IBundleInfo Bundle { get; private set; } + + /// + /// Uses the default location for BootstrapperApplicationData.xml. + /// + public BootstrapperApplicationData() : this(DefaultFile) { } + + /// + /// Uses the given file for BootstrapperApplicationData.xml. + /// + /// + public BootstrapperApplicationData(FileInfo baDataFile) + { + this.BADataFile = baDataFile; + + using (FileStream fs = this.BADataFile.OpenRead()) + { + this.Bundle = BundleInfo.ParseBundleFromStream(fs); + } + } + + /// + /// Utility method for parsing BootstrapperApplicationData.xml. + /// + /// + /// + /// + public static string GetAttribute(XPathNavigator node, string attributeName) + { + XPathNavigator attribute = node.SelectSingleNode("@" + attributeName); + + if (attribute == null) + { + return null; + } + + return attribute.Value; + } + + /// + /// Utility method for parsing BootstrapperApplicationData.xml. + /// + /// + /// + /// + public static bool? GetYesNoAttribute(XPathNavigator node, string attributeName) + { + string attributeValue = GetAttribute(node, attributeName); + + if (attributeValue == null) + { + return null; + } + + return attributeValue.Equals("yes", StringComparison.InvariantCulture); + } + } +} -- cgit v1.2.3-55-g6feb