aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.Burn/Bind/ProvidesDependency.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core.Burn/Bind/ProvidesDependency.cs')
-rw-r--r--src/WixToolset.Core.Burn/Bind/ProvidesDependency.cs108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/WixToolset.Core.Burn/Bind/ProvidesDependency.cs b/src/WixToolset.Core.Burn/Bind/ProvidesDependency.cs
new file mode 100644
index 00000000..e64773b4
--- /dev/null
+++ b/src/WixToolset.Core.Burn/Bind/ProvidesDependency.cs
@@ -0,0 +1,108 @@
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
3namespace WixToolset.Core.Burn
4{
5 using System;
6 using System.Xml;
7 using WixToolset.Data;
8
9 /// <summary>
10 /// Represents an authored or imported dependency provider.
11 /// </summary>
12 internal sealed class ProvidesDependency
13 {
14 /// <summary>
15 /// Creates a new instance of the <see cref="ProviderDependency"/> class from a <see cref="Row"/>.
16 /// </summary>
17 /// <param name="row">The <see cref="Row"/> from which data is imported.</param>
18 internal ProvidesDependency(Row row)
19 : this((string)row[2], (string)row[3], (string)row[4], (int?)row[5])
20 {
21 }
22
23 /// <summary>
24 /// Creates a new instance of the <see cref="ProviderDependency"/> class.
25 /// </summary>
26 /// <param name="key">The unique key of the dependency.</param>
27 /// <param name="attributes">Additional attributes for the dependency.</param>
28 internal ProvidesDependency(string key, string version, string displayName, int? attributes)
29 {
30 this.Key = key;
31 this.Version = version;
32 this.DisplayName = displayName;
33 this.Attributes = attributes;
34 }
35
36 /// <summary>
37 /// Gets or sets the unique key of the package provider.
38 /// </summary>
39 internal string Key { get; set; }
40
41 /// <summary>
42 /// Gets or sets the version of the package provider.
43 /// </summary>
44 internal string Version { get; set; }
45
46 /// <summary>
47 /// Gets or sets the display name of the package provider.
48 /// </summary>
49 internal string DisplayName { get; set; }
50
51 /// <summary>
52 /// Gets or sets the attributes for the dependency.
53 /// </summary>
54 internal int? Attributes { get; set; }
55
56 /// <summary>
57 /// Gets or sets whether the dependency was imported from the package.
58 /// </summary>
59 internal bool Imported { get; set; }
60
61 /// <summary>
62 /// Gets whether certain properties are the same.
63 /// </summary>
64 /// <param name="other">Another <see cref="ProvidesDependency"/> to compare.</param>
65 /// <remarks>This is not the same as object equality, but only checks a subset of properties
66 /// to determine if the objects are similar and could be merged into a collection.</remarks>
67 /// <returns>True if certain properties are the same.</returns>
68 internal bool Equals(ProvidesDependency other)
69 {
70 if (null != other)
71 {
72 return this.Key == other.Key &&
73 this.Version == other.Version &&
74 this.DisplayName == other.DisplayName;
75 }
76
77 return false;
78 }
79
80 /// <summary>
81 /// Writes the dependency to the bundle XML manifest.
82 /// </summary>
83 /// <param name="writer">The <see cref="XmlTextWriter"/> for the bundle XML manifest.</param>
84 internal void WriteXml(XmlTextWriter writer)
85 {
86 writer.WriteStartElement("Provides");
87 writer.WriteAttributeString("Key", this.Key);
88
89 if (!String.IsNullOrEmpty(this.Version))
90 {
91 writer.WriteAttributeString("Version", this.Version);
92 }
93
94 if (!String.IsNullOrEmpty(this.DisplayName))
95 {
96 writer.WriteAttributeString("DisplayName", this.DisplayName);
97 }
98
99 if (this.Imported)
100 {
101 // The package dependency was explicitly authored into the manifest.
102 writer.WriteAttributeString("Imported", "yes");
103 }
104
105 writer.WriteEndElement();
106 }
107 }
108}