// 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
{
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();
}
}
}