diff options
Diffstat (limited to 'src/WixToolset.Mba.Core/PackageInfo.cs')
-rw-r--r-- | src/WixToolset.Mba.Core/PackageInfo.cs | 64 |
1 files changed, 57 insertions, 7 deletions
diff --git a/src/WixToolset.Mba.Core/PackageInfo.cs b/src/WixToolset.Mba.Core/PackageInfo.cs index 46894d2e..d3199c08 100644 --- a/src/WixToolset.Mba.Core/PackageInfo.cs +++ b/src/WixToolset.Mba.Core/PackageInfo.cs | |||
@@ -34,17 +34,22 @@ namespace WixToolset.Mba.Core | |||
34 | public PackageType Type { get; internal set; } | 34 | public PackageType Type { get; internal set; } |
35 | public bool Permanent { get; internal set; } | 35 | public bool Permanent { get; internal set; } |
36 | public bool Vital { get; internal set; } | 36 | public bool Vital { get; internal set; } |
37 | public bool DisplayInternalUI { get; internal set; } | 37 | public string DisplayInternalUICondition { get; internal set; } |
38 | public string ProductCode { get; internal set; } | 38 | public string ProductCode { get; internal set; } |
39 | public string UpgradeCode { get; internal set; } | 39 | public string UpgradeCode { get; internal set; } |
40 | public string Version { get; internal set; } | 40 | public string Version { get; internal set; } |
41 | public string InstallCondition { get; internal set; } | 41 | public string InstallCondition { get; internal set; } |
42 | public CacheType CacheType { get; internal set; } | 42 | public CacheType CacheType { get; internal set; } |
43 | public bool PrereqPackage { get; internal set; } | ||
44 | public string PrereqLicenseFile { get; internal set; } | ||
45 | public string PrereqLicenseUrl { get; internal set; } | ||
46 | public object CustomData { get; set; } | ||
43 | 47 | ||
44 | internal PackageInfo() { } | 48 | internal PackageInfo() { } |
45 | 49 | ||
46 | public static IEnumerable<IPackageInfo> ParsePackagesFromXml(XPathNavigator root) | 50 | public static IDictionary<string, IPackageInfo> ParsePackagesFromXml(XPathNavigator root) |
47 | { | 51 | { |
52 | var packagesById = new Dictionary<string, IPackageInfo>(); | ||
48 | XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); | 53 | XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); |
49 | namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); | 54 | namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); |
50 | XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixPackageProperties", namespaceManager); | 55 | XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixPackageProperties", namespaceManager); |
@@ -85,9 +90,6 @@ namespace WixToolset.Mba.Core | |||
85 | } | 90 | } |
86 | package.Vital = vital.Value; | 91 | package.Vital = vital.Value; |
87 | 92 | ||
88 | bool? displayInternalUI = BootstrapperApplicationData.GetYesNoAttribute(node, "DisplayInternalUI"); | ||
89 | package.DisplayInternalUI = displayInternalUI.HasValue && displayInternalUI.Value; | ||
90 | |||
91 | package.ProductCode = BootstrapperApplicationData.GetAttribute(node, "ProductCode"); | 93 | package.ProductCode = BootstrapperApplicationData.GetAttribute(node, "ProductCode"); |
92 | 94 | ||
93 | package.UpgradeCode = BootstrapperApplicationData.GetAttribute(node, "UpgradeCode"); | 95 | package.UpgradeCode = BootstrapperApplicationData.GetAttribute(node, "UpgradeCode"); |
@@ -96,8 +98,11 @@ namespace WixToolset.Mba.Core | |||
96 | 98 | ||
97 | package.InstallCondition = BootstrapperApplicationData.GetAttribute(node, "InstallCondition"); | 99 | package.InstallCondition = BootstrapperApplicationData.GetAttribute(node, "InstallCondition"); |
98 | 100 | ||
99 | yield return package; | 101 | packagesById.Add(package.Id, package); |
100 | } | 102 | } |
103 | |||
104 | ParseBalPackageInfoFromXml(root, namespaceManager, packagesById); | ||
105 | return packagesById; | ||
101 | } | 106 | } |
102 | 107 | ||
103 | public static CacheType? GetCacheTypeAttribute(XPathNavigator node, string attributeName) | 108 | public static CacheType? GetCacheTypeAttribute(XPathNavigator node, string attributeName) |
@@ -154,7 +159,7 @@ namespace WixToolset.Mba.Core | |||
154 | } | 159 | } |
155 | } | 160 | } |
156 | 161 | ||
157 | public static PackageInfo GetRelatedBundleAsPackage(string id, RelationType relationType, bool perMachine, Version version) | 162 | public static IPackageInfo GetRelatedBundleAsPackage(string id, RelationType relationType, bool perMachine, Version version) |
158 | { | 163 | { |
159 | PackageInfo package = new PackageInfo(); | 164 | PackageInfo package = new PackageInfo(); |
160 | package.Id = id; | 165 | package.Id = id; |
@@ -177,5 +182,50 @@ namespace WixToolset.Mba.Core | |||
177 | 182 | ||
178 | return package; | 183 | return package; |
179 | } | 184 | } |
185 | |||
186 | internal static void ParseBalPackageInfoFromXml(XPathNavigator root, XmlNamespaceManager namespaceManager, Dictionary<string, IPackageInfo> packagesById) | ||
187 | { | ||
188 | XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixBalPackageInfo", namespaceManager); | ||
189 | |||
190 | foreach (XPathNavigator node in nodes) | ||
191 | { | ||
192 | string id = BootstrapperApplicationData.GetAttribute(node, "PackageId"); | ||
193 | if (id == null) | ||
194 | { | ||
195 | throw new Exception("Failed to get package identifier for WixBalPackageInfo."); | ||
196 | } | ||
197 | |||
198 | if (!packagesById.TryGetValue(id, out var ipackage)) | ||
199 | { | ||
200 | throw new Exception(string.Format("Failed to find package specified in WixBalPackageInfo: {0}", id)); | ||
201 | } | ||
202 | |||
203 | var package = (PackageInfo)ipackage; | ||
204 | |||
205 | package.DisplayInternalUICondition = BootstrapperApplicationData.GetAttribute(node, "DisplayInternalUICondition"); | ||
206 | } | ||
207 | |||
208 | nodes = root.Select("/p:BootstrapperApplicationData/p:WixMbaPrereqInformation", namespaceManager); | ||
209 | |||
210 | foreach (XPathNavigator node in nodes) | ||
211 | { | ||
212 | string id = BootstrapperApplicationData.GetAttribute(node, "PackageId"); | ||
213 | if (id == null) | ||
214 | { | ||
215 | throw new Exception("Failed to get package identifier for WixMbaPrereqInformation."); | ||
216 | } | ||
217 | |||
218 | if (!packagesById.TryGetValue(id, out var ipackage)) | ||
219 | { | ||
220 | throw new Exception(string.Format("Failed to find package specified in WixMbaPrereqInformation: {0}", id)); | ||
221 | } | ||
222 | |||
223 | var package = (PackageInfo)ipackage; | ||
224 | |||
225 | package.PrereqPackage = true; | ||
226 | package.PrereqLicenseFile = BootstrapperApplicationData.GetAttribute(node, "LicenseFile"); | ||
227 | package.PrereqLicenseUrl = BootstrapperApplicationData.GetAttribute(node, "LicenseUrl"); | ||
228 | } | ||
229 | } | ||
180 | } | 230 | } |
181 | } | 231 | } |