From ad653410d84b7423484933867d8231659cef638e Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 26 May 2019 00:44:51 +0100 Subject: [PATCH] Select only distinct density codes when creating device report. --- Metadata/DeviceReportV2.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Metadata/DeviceReportV2.cs b/Metadata/DeviceReportV2.cs index ed517cc..320c5ff 100644 --- a/Metadata/DeviceReportV2.cs +++ b/Metadata/DeviceReportV2.cs @@ -1683,9 +1683,30 @@ namespace DiscImageChef.CommonTypes.Metadata } } - public class DensityCode + public class DensityCode : IEquatable { + [JsonIgnore] [Key] + public int Id { get; set; } + public int Code { get; set; } + + public bool Equals(DensityCode other) + { + if(ReferenceEquals(null, other)) return false; + if(ReferenceEquals(this, other)) return true; + + return Code == other.Code; + } + + public override bool Equals(object obj) + { + if(ReferenceEquals(null, obj)) return false; + if(ReferenceEquals(this, obj)) return true; + + return obj.GetType() == GetType() && Equals((DensityCode)obj); + } + + public override int GetHashCode() => Code; } } \ No newline at end of file