2020-08-16 01:54:20 +00:00
|
|
|
using System;
|
2021-02-03 21:20:06 +00:00
|
|
|
using System.Text.Json.Serialization;
|
2014-01-18 11:44:36 +00:00
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Qualities
|
|
|
|
{
|
|
|
|
public class QualityModel : IEmbeddedDocument, IEquatable<QualityModel>
|
|
|
|
{
|
|
|
|
public Quality Quality { get; set; }
|
2018-08-05 14:28:05 +00:00
|
|
|
|
2014-09-01 02:28:42 +00:00
|
|
|
public Revision Revision { get; set; }
|
2018-08-05 14:28:05 +00:00
|
|
|
|
2015-10-23 05:21:44 +00:00
|
|
|
[JsonIgnore]
|
2020-08-16 01:54:20 +00:00
|
|
|
public QualityDetectionSource SourceDetectionSource { get; set; }
|
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
public QualityDetectionSource ResolutionDetectionSource { get; set; }
|
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
public QualityDetectionSource ModifierDetectionSource { get; set; }
|
2018-08-05 14:28:05 +00:00
|
|
|
|
2020-11-12 02:37:45 +00:00
|
|
|
[JsonIgnore]
|
|
|
|
public QualityDetectionSource RevisionDetectionSource { get; set; }
|
|
|
|
|
2014-01-18 11:44:36 +00:00
|
|
|
public QualityModel()
|
2014-09-01 02:28:42 +00:00
|
|
|
: this(Quality.Unknown, new Revision())
|
2014-01-18 11:44:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-01-22 21:47:33 +00:00
|
|
|
public QualityModel(Quality quality, Revision revision = null)
|
2014-01-18 11:44:36 +00:00
|
|
|
{
|
|
|
|
Quality = quality;
|
2014-09-01 02:28:42 +00:00
|
|
|
Revision = revision ?? new Revision();
|
2014-01-18 11:44:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
2020-01-22 21:47:33 +00:00
|
|
|
return string.Format("{0} {1}", Quality, Revision);
|
2014-01-18 11:44:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
// Overflow is fine, just wrap
|
|
|
|
unchecked
|
2014-01-18 11:44:36 +00:00
|
|
|
{
|
2023-05-23 10:52:39 +00:00
|
|
|
var hash = 17;
|
2019-12-22 22:08:53 +00:00
|
|
|
hash = (hash * 23) + Revision.GetHashCode();
|
|
|
|
hash = (hash * 23) + Quality.GetHashCode();
|
2014-01-18 11:44:36 +00:00
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool Equals(QualityModel other)
|
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
if (ReferenceEquals(null, other))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ReferenceEquals(this, other))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2014-09-01 02:28:42 +00:00
|
|
|
|
2018-08-05 14:28:05 +00:00
|
|
|
return other.Quality.Id.Equals(Quality.Id) && other.Revision.Equals(Revision);
|
2014-01-18 11:44:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
if (ReferenceEquals(null, obj))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ReferenceEquals(this, obj))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2014-01-18 11:44:36 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|