From dbde9e7104b907bbbaea17e21247d8cafc8b3a4c Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 14 Oct 2017 16:12:07 -0700 Subject: Massive refactoring to introduce the concept of IBackend --- .../Bind/ProvidesDependency.cs | 108 +++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/WixToolset.Core.Burn/Bind/ProvidesDependency.cs (limited to 'src/WixToolset.Core.Burn/Bind/ProvidesDependency.cs') 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 @@ +// 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.Core.Burn +{ + using System; + using System.Xml; + using WixToolset.Data; + + /// + /// Represents an authored or imported dependency provider. + /// + internal sealed class ProvidesDependency + { + /// + /// Creates a new instance of the class from a . + /// + /// The from which data is imported. + internal ProvidesDependency(Row row) + : this((string)row[2], (string)row[3], (string)row[4], (int?)row[5]) + { + } + + /// + /// Creates a new instance of the class. + /// + /// The unique key of the dependency. + /// Additional attributes for the dependency. + internal ProvidesDependency(string key, string version, string displayName, int? attributes) + { + this.Key = key; + this.Version = version; + this.DisplayName = displayName; + this.Attributes = attributes; + } + + /// + /// Gets or sets the unique key of the package provider. + /// + internal string Key { get; set; } + + /// + /// Gets or sets the version of the package provider. + /// + internal string Version { get; set; } + + /// + /// Gets or sets the display name of the package provider. + /// + internal string DisplayName { get; set; } + + /// + /// Gets or sets the attributes for the dependency. + /// + internal int? Attributes { get; set; } + + /// + /// Gets or sets whether the dependency was imported from the package. + /// + internal bool Imported { get; set; } + + /// + /// Gets whether certain properties are the same. + /// + /// Another to compare. + /// This is not the same as object equality, but only checks a subset of properties + /// to determine if the objects are similar and could be merged into a collection. + /// True if certain properties are the same. + internal bool Equals(ProvidesDependency other) + { + if (null != other) + { + return this.Key == other.Key && + this.Version == other.Version && + this.DisplayName == other.DisplayName; + } + + return false; + } + + /// + /// Writes the dependency to the bundle XML manifest. + /// + /// The for the bundle XML manifest. + internal void WriteXml(XmlTextWriter writer) + { + writer.WriteStartElement("Provides"); + writer.WriteAttributeString("Key", this.Key); + + if (!String.IsNullOrEmpty(this.Version)) + { + writer.WriteAttributeString("Version", this.Version); + } + + if (!String.IsNullOrEmpty(this.DisplayName)) + { + writer.WriteAttributeString("DisplayName", this.DisplayName); + } + + if (this.Imported) + { + // The package dependency was explicitly authored into the manifest. + writer.WriteAttributeString("Imported", "yes"); + } + + writer.WriteEndElement(); + } + } +} -- cgit v1.2.3-55-g6feb