namespace OliverBooth.Common.Data.Web;
///
/// Represents a site configuration item.
///
public sealed class SiteConfiguration : IEquatable
{
///
/// Gets or sets the name of the configuration item.
///
/// The name of the configuration item.
public string Key { get; set; } = string.Empty;
///
/// Gets or sets the value of the configuration item.
///
/// The value of the configuration item.
public string? Value { get; set; }
///
/// Returns a value indicating whether two instances of are equal.
///
/// The first instance of to compare.
/// The second instance of to compare.
///
/// if and are equal; otherwise,
/// .
///
public static bool operator ==(SiteConfiguration? left, SiteConfiguration? right) => Equals(left, right);
///
/// Returns a value indicating whether two instances of are not equal.
///
/// The first instance of to compare.
/// The second instance of to compare.
///
/// if and are not equal; otherwise,
/// .
///
public static bool operator !=(SiteConfiguration? left, SiteConfiguration? right) => !(left == right);
///
/// Returns a value indicating whether this instance of is equal to another
/// instance.
///
/// An instance to compare with this instance.
///
/// if is equal to this instance; otherwise,
/// .
///
public bool Equals(SiteConfiguration? other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return Key == other.Key;
}
///
/// Returns a value indicating whether this instance is equal to a specified object.
///
/// An object to compare with this instance.
///
/// if is an instance of and
/// equals the value of this instance; otherwise, .
///
public override bool Equals(object? obj)
{
return ReferenceEquals(this, obj) || obj is SiteConfiguration other && Equals(other);
}
///
/// Gets the hash code for this instance.
///
/// The hash code.
public override int GetHashCode()
{
// ReSharper disable once NonReadonlyMemberInGetHashCode
return Key.GetHashCode();
}
}