1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-18 23:48:35 +02:00
Sonarr/src/NzbDrone.Core/Qualities/QualityModel.cs

66 lines
1.7 KiB
C#
Raw Normal View History

using System;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Qualities
{
public class QualityModel : IEmbeddedDocument, IEquatable<QualityModel>
{
public Quality Quality { get; set; }
2014-09-01 05:28:42 +03:00
public Revision Revision { get; set; }
public QualityModel()
2014-09-01 05:28:42 +03:00
: this(Quality.Unknown, new Revision())
{
}
2014-09-01 05:28:42 +03:00
public QualityModel(Quality quality, Revision revision = null)
{
Quality = quality;
2014-09-01 05:28:42 +03:00
Revision = revision ?? new Revision();
}
public override string ToString()
{
2014-09-01 05:28:42 +03:00
return String.Format("{0} {1}", Quality, Revision);
}
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
int hash = 17;
2014-09-01 05:28:42 +03:00
hash = hash * 23 + Revision.GetHashCode();
hash = hash * 23 + Quality.GetHashCode();
return hash;
}
}
public bool Equals(QualityModel other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
2014-09-01 05:28:42 +03:00
return other.Quality.Equals(Quality) && other.Revision.Equals(Revision);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
return Equals(obj as QualityModel);
}
public static bool operator ==(QualityModel left, QualityModel right)
{
return Equals(left, right);
}
public static bool operator !=(QualityModel left, QualityModel right)
{
return !Equals(left, right);
}
}
}