2014-01-18 14:44:36 +03:00
|
|
|
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; }
|
2014-01-18 14:44:36 +03:00
|
|
|
|
|
|
|
public QualityModel()
|
2014-09-01 05:28:42 +03:00
|
|
|
: this(Quality.Unknown, new Revision())
|
2014-01-18 14:44:36 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-09-01 05:28:42 +03:00
|
|
|
public QualityModel(Quality quality, Revision revision = null)
|
2014-01-18 14:44:36 +03:00
|
|
|
{
|
|
|
|
Quality = quality;
|
2014-09-01 05:28:42 +03:00
|
|
|
Revision = revision ?? new Revision();
|
2014-01-18 14:44:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
2014-09-01 05:28:42 +03:00
|
|
|
return String.Format("{0} {1}", Quality, Revision);
|
2014-01-18 14:44:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2014-01-18 14:44:36 +03:00
|
|
|
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);
|
2014-01-18 14:44:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|