diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs
index b36185e13..14aaf153e 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs
@@ -127,7 +127,7 @@ namespace ImageSharp
///
public bool Equals(IccParametricCurve other)
{
- if (other == null)
+ if (ReferenceEquals(null, other))
{
return false;
}
@@ -138,13 +138,46 @@ namespace ImageSharp
}
return this.Type == other.Type
- && this.G == other.G
- && this.A == other.A
- && this.B == other.B
- && this.C == other.C
- && this.D == other.D
- && this.E == other.E
- && this.F == other.F;
+ && this.G.Equals(other.G)
+ && this.A.Equals(other.A)
+ && this.B.Equals(other.B)
+ && this.C.Equals(other.C)
+ && this.D.Equals(other.D)
+ && this.E.Equals(other.E)
+ && this.F.Equals(other.F);
+ }
+
+ ///
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccParametricCurve && this.Equals((IccParametricCurve)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = (int)this.Type;
+ hashCode = (hashCode * 397) ^ this.G.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.A.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.B.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.C.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.D.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.E.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.F.GetHashCode();
+ return hashCode;
+ }
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
index 346be9c42..a5816e212 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
@@ -51,7 +51,7 @@ namespace ImageSharp
///
public bool Equals(IccResponseCurve other)
{
- if (other == null)
+ if (ReferenceEquals(null, other))
{
return false;
}
@@ -66,6 +66,34 @@ namespace ImageSharp
&& this.EqualsResponseArray(other);
}
+ ///
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccResponseCurve && this.Equals((IccResponseCurve)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = (int)this.CurveType;
+ hashCode = (hashCode * 397) ^ (this.XyzValues != null ? this.XyzValues.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.ResponseArrays != null ? this.ResponseArrays.GetHashCode() : 0);
+ return hashCode;
+ }
+ }
+
private bool EqualsResponseArray(IccResponseCurve other)
{
if (this.ResponseArrays.Length != other.ResponseArrays.Length)
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs
index 94529b929..5db3d96ea 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs
@@ -43,10 +43,36 @@ namespace ImageSharp
///
public IccProfileTag TagSignature { get; set; }
+ ///
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ var entry = obj as IccTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (int)this.Signature * 397;
+ }
+ }
+
///
public virtual bool Equals(IccTagDataEntry other)
{
- if (other == null)
+ if (ReferenceEquals(null, other))
{
return false;
}
@@ -56,8 +82,7 @@ namespace ImageSharp
return true;
}
- return this.Signature == other.Signature
- && this.TagSignature == other.TagSignature;
+ return this.Signature == other.Signature;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs
index de2823387..b4e5f2868 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs
@@ -79,7 +79,6 @@ namespace ImageSharp
var inData = new List(entries);
var dupData = new List();
- // Filter out duplicate entries. They only need to be defined once but can be used multiple times
while (inData.Count > 0)
{
IccTagDataEntry[] items = inData.Where(t => inData[0].Equals(t)).ToArray();
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
index 235988498..85f40f5e4 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
@@ -69,10 +69,7 @@ namespace ImageSharp
///
/// Gets the number of channels
///
- public int ChannelCount
- {
- get { return this.ChannelValues.Length; }
- }
+ public int ChannelCount => this.ChannelValues.Length;
///
/// Gets the colorant type
@@ -84,22 +81,55 @@ namespace ImageSharp
///
public double[][] ChannelValues { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccChromaticityTagDataEntry entry)
+ var entry = other as IccChromaticityTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccChromaticityTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
{
- return this.ColorantType == entry.ColorantType
- && this.EqualsChannelValues(entry);
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
+ {
+ return true;
}
- return false;
+ return base.Equals(other) && this.ColorantType == other.ColorantType && this.EqualsChannelValues(other);
}
- ///
- public bool Equals(IccChromaticityTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccChromaticityTagDataEntry && this.Equals((IccChromaticityTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ (int)this.ColorantType;
+ hashCode = (hashCode * 397) ^ (this.ChannelValues != null ? this.ChannelValues.GetHashCode() : 0);
+ return hashCode;
+ }
}
private static double[][] GetColorantArray(IccColorantEncoding colorantType)
@@ -107,32 +137,32 @@ namespace ImageSharp
switch (colorantType)
{
case IccColorantEncoding.EbuTech3213E:
- return new double[][]
+ return new[]
{
- new double[] { 0.640, 0.330 },
- new double[] { 0.290, 0.600 },
- new double[] { 0.150, 0.060 },
+ new[] { 0.640, 0.330 },
+ new[] { 0.290, 0.600 },
+ new[] { 0.150, 0.060 },
};
case IccColorantEncoding.ItuRBt709_2:
- return new double[][]
+ return new[]
{
- new double[] { 0.640, 0.330 },
- new double[] { 0.300, 0.600 },
- new double[] { 0.150, 0.060 },
+ new[] { 0.640, 0.330 },
+ new[] { 0.300, 0.600 },
+ new[] { 0.150, 0.060 },
};
case IccColorantEncoding.P22:
- return new double[][]
+ return new[]
{
- new double[] { 0.625, 0.340 },
- new double[] { 0.280, 0.605 },
- new double[] { 0.155, 0.070 },
+ new[] { 0.625, 0.340 },
+ new[] { 0.280, 0.605 },
+ new[] { 0.155, 0.070 },
};
case IccColorantEncoding.SmpteRp145:
- return new double[][]
+ return new[]
{
- new double[] { 0.630, 0.340 },
- new double[] { 0.310, 0.595 },
- new double[] { 0.155, 0.070 },
+ new[] { 0.630, 0.340 },
+ new[] { 0.310, 0.595 },
+ new[] { 0.155, 0.070 },
};
default:
throw new ArgumentException("Unrecognized colorant encoding");
@@ -157,4 +187,4 @@ namespace ImageSharp
return true;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
index 08875f085..9be5541a2 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
@@ -42,21 +42,52 @@ namespace ImageSharp
///
public byte[] ColorantNumber { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccColorantOrderTagDataEntry entry)
+ var entry = other as IccColorantOrderTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccColorantOrderTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.ColorantNumber.SequenceEqual(entry.ColorantNumber);
+ return true;
}
- return false;
+ return base.Equals(other) && this.ColorantNumber.SequenceEqual(other.ColorantNumber);
}
- ///
- public bool Equals(IccColorantOrderTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccColorantOrderTagDataEntry && this.Equals((IccColorantOrderTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.ColorantNumber != null ? this.ColorantNumber.GetHashCode() : 0);
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
index e9411da4d..041f74f39 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
@@ -43,21 +43,52 @@ namespace ImageSharp
///
public IccColorantTableEntry[] ColorantData { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccColorantTableTagDataEntry entry)
+ var entry = other as IccColorantTableTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccColorantTableTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.ColorantData.SequenceEqual(entry.ColorantData);
+ return true;
}
- return false;
+ return base.Equals(other) && this.ColorantData.SequenceEqual(other.ColorantData);
}
- ///
- public bool Equals(IccColorantTableTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccColorantTableTagDataEntry && this.Equals((IccColorantTableTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.ColorantData != null ? this.ColorantData.GetHashCode() : 0);
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
index 29edc78d0..73588bbf0 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
@@ -87,25 +87,63 @@ namespace ImageSharp
///
public string RenderingIntent3Crd { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccCrdInfoTagDataEntry entry)
+ var entry = other as IccCrdInfoTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccCrdInfoTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.PostScriptProductName == entry.PostScriptProductName
- && this.RenderingIntent0Crd == entry.RenderingIntent0Crd
- && this.RenderingIntent1Crd == entry.RenderingIntent1Crd
- && this.RenderingIntent2Crd == entry.RenderingIntent2Crd
- && this.RenderingIntent3Crd == entry.RenderingIntent3Crd;
+ return true;
}
- return false;
+ return base.Equals(other)
+ && string.Equals(this.PostScriptProductName, other.PostScriptProductName)
+ && string.Equals(this.RenderingIntent0Crd, other.RenderingIntent0Crd)
+ && string.Equals(this.RenderingIntent1Crd, other.RenderingIntent1Crd)
+ && string.Equals(this.RenderingIntent2Crd, other.RenderingIntent2Crd)
+ && string.Equals(this.RenderingIntent3Crd, other.RenderingIntent3Crd);
}
- ///
- public bool Equals(IccCrdInfoTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccCrdInfoTagDataEntry && this.Equals((IccCrdInfoTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ (this.PostScriptProductName != null ? this.PostScriptProductName.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.RenderingIntent0Crd != null ? this.RenderingIntent0Crd.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.RenderingIntent1Crd != null ? this.RenderingIntent1Crd.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.RenderingIntent2Crd != null ? this.RenderingIntent2Crd.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.RenderingIntent3Crd != null ? this.RenderingIntent3Crd.GetHashCode() : 0);
+ return hashCode;
+ }
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
index de2553dc5..c14995748 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
@@ -26,7 +26,7 @@ namespace ImageSharp
///
/// Gamma value
public IccCurveTagDataEntry(float gamma)
- : this(new float[] { gamma }, IccProfileTag.Unknown)
+ : this(new[] { gamma }, IccProfileTag.Unknown)
{
}
@@ -54,7 +54,7 @@ namespace ImageSharp
/// Gamma value
/// Tag Signature
public IccCurveTagDataEntry(float gamma, IccProfileTag tagSignature)
- : this(new float[] { gamma }, tagSignature)
+ : this(new[] { gamma }, tagSignature)
{
}
@@ -78,52 +78,64 @@ namespace ImageSharp
/// Gets the gamma value.
/// Only valid if is true
///
- public float Gamma
- {
- get
- {
- if (this.IsGamma)
- {
- return this.CurveData[0];
- }
- else
- {
- return 0;
- }
- }
- }
+ public float Gamma => this.IsGamma ? this.CurveData[0] : 0;
///
/// Gets a value indicating whether the curve maps input directly to output
///
- public bool IsIdentityResponse
- {
- get { return this.CurveData.Length == 0; }
- }
+ public bool IsIdentityResponse => this.CurveData.Length == 0;
///
/// Gets a value indicating whether the curve is a gamma curve
///
- public bool IsGamma
+ public bool IsGamma => this.CurveData.Length == 1;
+
+ ///
+ public override bool Equals(IccTagDataEntry other)
{
- get { return this.CurveData.Length == 1; }
+ var entry = other as IccCurveTagDataEntry;
+ return entry != null && this.Equals(entry);
}
- ///
- public override bool Equals(IccTagDataEntry other)
+ ///
+ public bool Equals(IccCurveTagDataEntry other)
{
- if (base.Equals(other) && other is IccCurveTagDataEntry entry)
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.CurveData.SequenceEqual(entry.CurveData);
+ return true;
}
- return false;
+ return base.Equals(other) && this.CurveData.SequenceEqual(other.CurveData);
}
- ///
- public bool Equals(IccCurveTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccCurveTagDataEntry && this.Equals((IccCurveTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
{
- return this.Equals((IccTagDataEntry)other);
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.CurveData != null ? this.CurveData.GetHashCode() : 0);
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
index c2bfacf53..57f04b11a 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
@@ -64,37 +64,57 @@ namespace ImageSharp
/// Gets the decoded as 7bit ASCII.
/// If is false, returns null
///
- public string AsciiString
+ public string AsciiString => this.IsAscii ? AsciiEncoding.GetString(this.Data, 0, this.Data.Length) : null;
+
+ ///
+ public override bool Equals(IccTagDataEntry other)
{
- get
+ var entry = other as IccDataTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccDataTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- if (this.IsAscii)
- {
- return AsciiEncoding.GetString(this.Data, 0, this.Data.Length);
- }
- else
- {
- return null;
- }
+ return true;
}
+
+ return base.Equals(other) && this.Data.SequenceEqual(other.Data) && this.IsAscii == other.IsAscii;
}
- ///
- public override bool Equals(IccTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- if (base.Equals(other) && other is IccDataTagDataEntry entry)
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
{
- return this.IsAscii == entry.IsAscii
- && this.Data.SequenceEqual(entry.Data);
+ return true;
}
- return false;
+ return obj is IccDataTagDataEntry && this.Equals((IccDataTagDataEntry)obj);
}
- ///
- public bool Equals(IccDataTagDataEntry other)
+ ///
+ public override int GetHashCode()
{
- return this.Equals((IccTagDataEntry)other);
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ this.IsAscii.GetHashCode();
+ return hashCode;
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
index 531327032..7111913cb 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
@@ -37,21 +37,52 @@ namespace ImageSharp
///
public DateTime Value { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccDateTimeTagDataEntry entry)
+ var entry = other as IccDateTimeTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccDateTimeTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.Value == entry.Value;
+ return true;
}
- return false;
+ return base.Equals(other) && this.Value.Equals(other.Value);
}
- ///
- public bool Equals(IccDateTimeTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccDateTimeTagDataEntry && this.Equals((IccDateTimeTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ this.Value.GetHashCode();
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
index af1a7aa42..c91347d23 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
@@ -39,21 +39,52 @@ namespace ImageSharp
///
public float[] Data { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccFix16ArrayTagDataEntry entry)
+ var entry = other as IccFix16ArrayTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccFix16ArrayTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.Data.SequenceEqual(entry.Data);
+ return true;
}
- return false;
+ return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
- ///
- public bool Equals(IccFix16ArrayTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccFix16ArrayTagDataEntry && this.Equals((IccFix16ArrayTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
index 5080b2313..45d7b3c50 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
@@ -83,18 +83,12 @@ namespace ImageSharp
///
/// Gets the number of input channels
///
- public int InputChannelCount
- {
- get { return this.InputValues.Length; }
- }
+ public int InputChannelCount => this.InputValues.Length;
///
/// Gets the number of output channels
///
- public int OutputChannelCount
- {
- get { return this.OutputValues.Length; }
- }
+ public int OutputChannelCount => this.OutputValues.Length;
///
/// Gets the conversion matrix
@@ -116,24 +110,61 @@ namespace ImageSharp
///
public IccLut[] OutputValues { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccLut16TagDataEntry entry)
+ var entry = other as IccLut16TagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccLut16TagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.ClutValues.Equals(entry.ClutValues)
- && this.Matrix == entry.Matrix
- && this.InputValues.SequenceEqual(entry.InputValues)
- && this.OutputValues.SequenceEqual(entry.OutputValues);
+ return true;
}
- return false;
+ return base.Equals(other)
+ && this.Matrix.Equals(other.Matrix)
+ && this.InputValues.SequenceEqual(other.InputValues)
+ && this.ClutValues.Equals(other.ClutValues)
+ && this.OutputValues.SequenceEqual(other.OutputValues);
}
- ///
- public bool Equals(IccLut16TagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccLut16TagDataEntry && this.Equals((IccLut16TagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.Matrix.GetHashCode();
+ hashCode = (hashCode * 397) ^ (this.InputValues != null ? this.InputValues.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.OutputValues != null ? this.OutputValues.GetHashCode() : 0);
+ return hashCode;
+ }
}
private Matrix4x4 CreateMatrix(float[,] matrix)
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
index d3c41dde3..538cf0505 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
@@ -86,18 +86,12 @@ namespace ImageSharp
///
/// Gets the number of input channels
///
- public int InputChannelCount
- {
- get { return this.InputValues.Length; }
- }
+ public int InputChannelCount => this.InputValues.Length;
///
/// Gets the number of output channels
///
- public int OutputChannelCount
- {
- get { return this.OutputValues.Length; }
- }
+ public int OutputChannelCount => this.OutputValues.Length;
///
/// Gets the conversion matrix
@@ -119,24 +113,61 @@ namespace ImageSharp
///
public IccLut[] OutputValues { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccLut8TagDataEntry entry)
+ var entry = other as IccLut8TagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccLut8TagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.ClutValues.Equals(entry.ClutValues)
- && this.Matrix == entry.Matrix
- && this.InputValues.SequenceEqual(entry.InputValues)
- && this.OutputValues.SequenceEqual(entry.OutputValues);
+ return true;
}
- return false;
+ return base.Equals(other)
+ && this.Matrix.Equals(other.Matrix)
+ && this.InputValues.SequenceEqual(other.InputValues)
+ && this.ClutValues.Equals(other.ClutValues)
+ && this.OutputValues.SequenceEqual(other.OutputValues);
}
- ///
- public bool Equals(IccLut8TagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccLut8TagDataEntry && this.Equals((IccLut8TagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.Matrix.GetHashCode();
+ hashCode = (hashCode * 397) ^ (this.InputValues != null ? this.InputValues.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.OutputValues != null ? this.OutputValues.GetHashCode() : 0);
+ return hashCode;
+ }
}
private Matrix4x4 CreateMatrix(float[,] matrix)
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
index cfbb64714..d440447cc 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
@@ -146,28 +146,69 @@ namespace ImageSharp
///
public IccTagDataEntry[] CurveA { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccLutAToBTagDataEntry entry)
+ var entry = other as IccLutAToBTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccLutAToBTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.InputChannelCount == entry.InputChannelCount
- && this.OutputChannelCount == entry.OutputChannelCount
- && this.Matrix3x1 == entry.Matrix3x1
- && this.Matrix3x3 == entry.Matrix3x3
- && this.ClutValues.Equals(entry.ClutValues)
- && this.EqualsCurve(this.CurveA, entry.CurveA)
- && this.EqualsCurve(this.CurveB, entry.CurveB)
- && this.EqualsCurve(this.CurveM, entry.CurveM);
+ return true;
}
- return false;
+ return base.Equals(other)
+ && this.InputChannelCount == other.InputChannelCount
+ && this.OutputChannelCount == other.OutputChannelCount
+ && this.Matrix3x3.Equals(other.Matrix3x3)
+ && this.Matrix3x1.Equals(other.Matrix3x1)
+ && this.ClutValues.Equals(other.ClutValues)
+ && this.EqualsCurve(this.CurveB, other.CurveB)
+ && this.EqualsCurve(this.CurveM, other.CurveM)
+ && this.EqualsCurve(this.CurveA, other.CurveA);
}
- ///
- public bool Equals(IccLutAToBTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccLutAToBTagDataEntry && this.Equals((IccLutAToBTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.InputChannelCount;
+ hashCode = (hashCode * 397) ^ this.OutputChannelCount;
+ hashCode = (hashCode * 397) ^ this.Matrix3x3.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.Matrix3x1.GetHashCode();
+ hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.CurveB != null ? this.CurveB.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.CurveM != null ? this.CurveM.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.CurveA != null ? this.CurveA.GetHashCode() : 0);
+ return hashCode;
+ }
}
private bool EqualsCurve(IccTagDataEntry[] thisCurves, IccTagDataEntry[] entryCurves)
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
index e0bcab7be..9d63dd171 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
@@ -146,28 +146,69 @@ namespace ImageSharp
///
public IccTagDataEntry[] CurveA { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccLutBToATagDataEntry entry)
+ var entry = other as IccLutBToATagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccLutBToATagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.InputChannelCount == entry.InputChannelCount
- && this.OutputChannelCount == entry.OutputChannelCount
- && this.Matrix3x1 == entry.Matrix3x1
- && this.Matrix3x3 == entry.Matrix3x3
- && this.ClutValues.Equals(entry.ClutValues)
- && this.EqualsCurve(this.CurveA, entry.CurveA)
- && this.EqualsCurve(this.CurveB, entry.CurveB)
- && this.EqualsCurve(this.CurveM, entry.CurveM);
+ return true;
}
- return false;
+ return base.Equals(other)
+ && this.InputChannelCount == other.InputChannelCount
+ && this.OutputChannelCount == other.OutputChannelCount
+ && this.Matrix3x3.Equals(other.Matrix3x3)
+ && this.Matrix3x1.Equals(other.Matrix3x1)
+ && this.ClutValues.Equals(other.ClutValues)
+ && this.EqualsCurve(this.CurveB, other.CurveB)
+ && this.EqualsCurve(this.CurveM, other.CurveM)
+ && this.EqualsCurve(this.CurveA, other.CurveA);
}
- ///
- public bool Equals(IccLutBToATagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccLutBToATagDataEntry && this.Equals((IccLutBToATagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.InputChannelCount;
+ hashCode = (hashCode * 397) ^ this.OutputChannelCount;
+ hashCode = (hashCode * 397) ^ this.Matrix3x3.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.Matrix3x1.GetHashCode();
+ hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.CurveB != null ? this.CurveB.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.CurveM != null ? this.CurveM.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.CurveA != null ? this.CurveA.GetHashCode() : 0);
+ return hashCode;
+ }
}
private bool EqualsCurve(IccTagDataEntry[] thisCurves, IccTagDataEntry[] entryCurves)
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
index b63e4a20b..390a5ba54 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
@@ -72,25 +72,63 @@ namespace ImageSharp
///
public IccStandardIlluminant Illuminant { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccMeasurementTagDataEntry entry)
+ var entry = other as IccMeasurementTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccMeasurementTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.Observer == entry.Observer
- && this.XyzBacking == entry.XyzBacking
- && this.Geometry == entry.Geometry
- && this.Flare == entry.Flare
- && this.Illuminant == entry.Illuminant;
+ return true;
}
- return false;
+ return base.Equals(other)
+ && this.Observer == other.Observer
+ && this.XyzBacking.Equals(other.XyzBacking)
+ && this.Geometry == other.Geometry
+ && this.Flare.Equals(other.Flare)
+ && this.Illuminant == other.Illuminant;
}
- ///
- public bool Equals(IccMeasurementTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccMeasurementTagDataEntry && this.Equals((IccMeasurementTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ (int)this.Observer;
+ hashCode = (hashCode * 397) ^ this.XyzBacking.GetHashCode();
+ hashCode = (hashCode * 397) ^ (int)this.Geometry;
+ hashCode = (hashCode * 397) ^ this.Flare.GetHashCode();
+ hashCode = (hashCode * 397) ^ (int)this.Illuminant;
+ return hashCode;
+ }
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
index c5af2399b..573e77ed4 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
@@ -40,21 +40,52 @@ namespace ImageSharp
///
public IccLocalizedString[] Texts { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccMultiLocalizedUnicodeTagDataEntry entry)
+ var entry = other as IccMultiLocalizedUnicodeTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccMultiLocalizedUnicodeTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ return base.Equals(other) && this.Texts.SequenceEqual(other.Texts);
+ }
+
+ ///
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
{
- return this.Texts.SequenceEqual(entry.Texts);
+ return true;
}
- return false;
+ return obj is IccMultiLocalizedUnicodeTagDataEntry && this.Equals((IccMultiLocalizedUnicodeTagDataEntry)obj);
}
///
- public bool Equals(IccMultiLocalizedUnicodeTagDataEntry other)
+ public override int GetHashCode()
{
- return this.Equals((IccTagDataEntry)other);
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.Texts != null ? this.Texts.GetHashCode() : 0);
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs
index 5ebfbbb6e..e3e6ef143 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs
@@ -57,23 +57,59 @@ namespace ImageSharp
///
public IccMultiProcessElement[] Data { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccMultiProcessElementsTagDataEntry entry)
+ var entry = other as IccMultiProcessElementsTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccMultiProcessElementsTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.InputChannelCount == entry.InputChannelCount
- && this.OutputChannelCount == entry.OutputChannelCount
- && this.Data.SequenceEqual(entry.Data);
+ return true;
}
- return false;
+ return base.Equals(other)
+ && this.InputChannelCount == other.InputChannelCount
+ && this.OutputChannelCount == other.OutputChannelCount
+ && this.Data.SequenceEqual(other.Data);
}
- ///
- public bool Equals(IccMultiProcessElementsTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccMultiProcessElementsTagDataEntry && this.Equals((IccMultiProcessElementsTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.InputChannelCount;
+ hashCode = (hashCode * 397) ^ this.OutputChannelCount;
+ hashCode = (hashCode * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ return hashCode;
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
index 6b354b311..17b7213b2 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
@@ -120,25 +120,63 @@ namespace ImageSharp
///
public IccNamedColor[] Colors { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccNamedColor2TagDataEntry entry)
+ var entry = other as IccNamedColor2TagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccNamedColor2TagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.CoordinateCount == entry.CoordinateCount
- && this.Prefix == entry.Prefix
- && this.Suffix == entry.Suffix
- && this.VendorFlags == entry.VendorFlags
- && this.Colors.SequenceEqual(entry.Colors);
+ return true;
}
- return false;
+ return base.Equals(other)
+ && this.CoordinateCount == other.CoordinateCount
+ && string.Equals(this.Prefix, other.Prefix)
+ && string.Equals(this.Suffix, other.Suffix)
+ && this.VendorFlags == other.VendorFlags
+ && this.Colors.SequenceEqual(other.Colors);
}
- ///
- public bool Equals(IccNamedColor2TagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccNamedColor2TagDataEntry && this.Equals((IccNamedColor2TagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.CoordinateCount;
+ hashCode = (hashCode * 397) ^ (this.Prefix != null ? this.Prefix.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.Suffix != null ? this.Suffix.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ this.VendorFlags;
+ hashCode = (hashCode * 397) ^ (this.Colors != null ? this.Colors.GetHashCode() : 0);
+ return hashCode;
+ }
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
index 779656911..4264c0b24 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
@@ -38,21 +38,52 @@ namespace ImageSharp
///
public IccParametricCurve Curve { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccParametricCurveTagDataEntry entry)
+ var entry = other as IccParametricCurveTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccParametricCurveTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ return base.Equals(other) && this.Curve.Equals(other.Curve);
+ }
+
+ ///
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
{
- return this.Curve.Equals(entry.Curve);
+ return true;
}
- return false;
+ return obj is IccParametricCurveTagDataEntry && this.Equals((IccParametricCurveTagDataEntry)obj);
}
///
- public bool Equals(IccParametricCurveTagDataEntry other)
+ public override int GetHashCode()
{
- return this.Equals((IccTagDataEntry)other);
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.Curve != null ? this.Curve.GetHashCode() : 0);
+ }
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
index ef9da652b..547483e23 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
@@ -41,21 +41,52 @@ namespace ImageSharp
///
public IccProfileDescription[] Descriptions { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccProfileSequenceDescTagDataEntry entry)
+ var entry = other as IccProfileSequenceDescTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccProfileSequenceDescTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
{
- return this.Descriptions.SequenceEqual(entry.Descriptions);
+ return false;
}
- return false;
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ return base.Equals(other) && this.Descriptions.SequenceEqual(other.Descriptions);
+ }
+
+ ///
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccProfileSequenceDescTagDataEntry && this.Equals((IccProfileSequenceDescTagDataEntry)obj);
}
///
- public bool Equals(IccProfileSequenceDescTagDataEntry other)
+ public override int GetHashCode()
{
- return this.Equals((IccTagDataEntry)other);
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.Descriptions != null ? this.Descriptions.GetHashCode() : 0);
+ }
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
index 480f3974b..1a1b02c0b 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
@@ -40,21 +40,52 @@ namespace ImageSharp
///
public IccProfileSequenceIdentifier[] Data { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccProfileSequenceIdentifierTagDataEntry entry)
+ var entry = other as IccProfileSequenceIdentifierTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccProfileSequenceIdentifierTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
{
- return this.Data.SequenceEqual(entry.Data);
+ return false;
}
- return false;
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
///
- public bool Equals(IccProfileSequenceIdentifierTagDataEntry other)
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccProfileSequenceIdentifierTagDataEntry && this.Equals((IccProfileSequenceIdentifierTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
{
- return this.Equals((IccTagDataEntry)other);
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ }
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs
index 1a4788aad..f4fc7fbd2 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs
@@ -52,22 +52,57 @@ namespace ImageSharp
///
public IccResponseCurve[] Curves { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccResponseCurveSet16TagDataEntry entry)
+ var entry = other as IccResponseCurveSet16TagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccResponseCurveSet16TagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
{
- return this.ChannelCount == entry.ChannelCount
- && this.Curves.SequenceEqual(entry.Curves);
+ return false;
}
- return false;
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ return base.Equals(other)
+ && this.ChannelCount == other.ChannelCount
+ && this.Curves.SequenceEqual(other.Curves);
}
///
- public bool Equals(IccResponseCurveSet16TagDataEntry other)
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccResponseCurveSet16TagDataEntry && this.Equals((IccResponseCurveSet16TagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
{
- return this.Equals((IccTagDataEntry)other);
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.ChannelCount.GetHashCode();
+ hashCode = (hashCode * 397) ^ (this.Curves != null ? this.Curves.GetHashCode() : 0);
+ return hashCode;
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
index 166f74b37..8c3a2d83b 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
@@ -49,22 +49,57 @@ namespace ImageSharp
///
public IccScreeningChannel[] Channels { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccScreeningTagDataEntry entry)
+ var entry = other as IccScreeningTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccScreeningTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
{
- return this.Flags == entry.Flags
- && this.Channels.SequenceEqual(entry.Channels);
+ return false;
}
- return false;
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ return base.Equals(other)
+ && this.Flags == other.Flags
+ && this.Channels.SequenceEqual(other.Channels);
}
///
- public bool Equals(IccScreeningTagDataEntry other)
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccScreeningTagDataEntry && this.Equals((IccScreeningTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ (int)this.Flags;
+ hashCode = (hashCode * 397) ^ (this.Channels != null ? this.Channels.GetHashCode() : 0);
+ return hashCode;
+ }
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
index 9ee9c8fa3..9ce2c1b9a 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
@@ -39,21 +39,52 @@ namespace ImageSharp
///
public string SignatureData { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccSignatureTagDataEntry entry)
+ var entry = other as IccSignatureTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccSignatureTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
{
- return this.SignatureData == entry.SignatureData;
+ return false;
}
- return false;
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ return base.Equals(other) && string.Equals(this.SignatureData, other.SignatureData);
}
///
- public bool Equals(IccSignatureTagDataEntry other)
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccSignatureTagDataEntry && this.Equals((IccSignatureTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
{
- return this.Equals((IccTagDataEntry)other);
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.SignatureData != null ? this.SignatureData.GetHashCode() : 0);
+ }
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
index b87538196..202220f93 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
@@ -87,14 +87,9 @@ namespace ImageSharp
if (!string.IsNullOrEmpty(textEntry.Unicode))
{
CultureInfo culture = GetCulture(textEntry.UnicodeLanguageCode);
- if (culture != null)
- {
- localString = new IccLocalizedString(culture, textEntry.Unicode);
- }
- else
- {
- localString = new IccLocalizedString(textEntry.Unicode);
- }
+ localString = culture != null
+ ? new IccLocalizedString(culture, textEntry.Unicode)
+ : new IccLocalizedString(textEntry.Unicode);
}
else if (!string.IsNullOrEmpty(textEntry.Ascii))
{
@@ -109,7 +104,7 @@ namespace ImageSharp
localString = new IccLocalizedString(string.Empty);
}
- return new IccMultiLocalizedUnicodeTagDataEntry(new IccLocalizedString[] { localString }, textEntry.TagSignature);
+ return new IccMultiLocalizedUnicodeTagDataEntry(new[] { localString }, textEntry.TagSignature);
CultureInfo GetCulture(uint value)
{
@@ -129,35 +124,71 @@ namespace ImageSharp
&& p3 >= 0x41 && p3 <= 0x5A
&& p4 >= 0x41 && p4 <= 0x5A)
{
- string culture = new string(new char[] { (char)p1, (char)p2, '-', (char)p3, (char)p4 });
+ string culture = new string(new[] { (char)p1, (char)p2, '-', (char)p3, (char)p4 });
return new CultureInfo(culture);
}
- else
- {
- return null;
- }
+
+ return null;
}
}
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccTextDescriptionTagDataEntry entry)
+ var entry = other as IccTextDescriptionTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccTextDescriptionTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
{
- return this.Ascii == entry.Ascii
- && this.Unicode == entry.Unicode
- && this.ScriptCode == entry.ScriptCode
- && this.UnicodeLanguageCode == entry.UnicodeLanguageCode
- && this.ScriptCodeCode == entry.ScriptCodeCode;
+ return false;
}
- return false;
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ return base.Equals(other)
+ && string.Equals(this.Ascii, other.Ascii)
+ && string.Equals(this.Unicode, other.Unicode)
+ && string.Equals(this.ScriptCode, other.ScriptCode)
+ && this.UnicodeLanguageCode == other.UnicodeLanguageCode
+ && this.ScriptCodeCode == other.ScriptCodeCode;
}
///
- public bool Equals(IccTextDescriptionTagDataEntry other)
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccTextDescriptionTagDataEntry && this.Equals((IccTextDescriptionTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ (this.Ascii != null ? this.Ascii.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.Unicode != null ? this.Unicode.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.ScriptCode != null ? this.ScriptCode.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (int)this.UnicodeLanguageCode;
+ hashCode = (hashCode * 397) ^ this.ScriptCodeCode.GetHashCode();
+ return hashCode;
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs
index cb102eaaf..9e56a1cf8 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs
@@ -38,21 +38,52 @@ namespace ImageSharp
///
public string Text { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccTextTagDataEntry entry)
+ var entry = other as IccTextTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccTextTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
{
- return this.Text == entry.Text;
+ return false;
}
- return false;
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ return base.Equals(other) && string.Equals(this.Text, other.Text);
}
///
- public bool Equals(IccTextTagDataEntry other)
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccTextTagDataEntry && this.Equals((IccTextTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
{
- return this.Equals((IccTagDataEntry)other);
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.Text != null ? this.Text.GetHashCode() : 0);
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs
index 3c326c994..2b7b4044d 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs
@@ -39,21 +39,52 @@ namespace ImageSharp
///
public float[] Data { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccUFix16ArrayTagDataEntry entry)
+ var entry = other as IccUFix16ArrayTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccUFix16ArrayTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.Data.SequenceEqual(entry.Data);
+ return true;
}
- return false;
+ return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
- ///
- public bool Equals(IccUFix16ArrayTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccUFix16ArrayTagDataEntry && this.Equals((IccUFix16ArrayTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
index b290fc5fe..da7725310 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
@@ -39,21 +39,52 @@ namespace ImageSharp
///
public ushort[] Data { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccUInt16ArrayTagDataEntry entry)
+ var entry = other as IccUInt16ArrayTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccUInt16ArrayTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.Data.SequenceEqual(entry.Data);
+ return true;
}
- return false;
+ return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
- ///
- public bool Equals(IccUInt16ArrayTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccUInt16ArrayTagDataEntry && this.Equals((IccUInt16ArrayTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ }
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
index 2cf0b4fcc..0dabdecc1 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
@@ -39,21 +39,52 @@ namespace ImageSharp
///
public uint[] Data { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccUInt32ArrayTagDataEntry entry)
+ var entry = other as IccUInt32ArrayTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccUInt32ArrayTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.Data.SequenceEqual(entry.Data);
+ return true;
}
- return false;
+ return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
- ///
- public bool Equals(IccUInt32ArrayTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccUInt32ArrayTagDataEntry && this.Equals((IccUInt32ArrayTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
index 6f6ce88bd..d62a4a8a7 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
@@ -39,21 +39,52 @@ namespace ImageSharp
///
public ulong[] Data { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccUInt64ArrayTagDataEntry entry)
+ var entry = other as IccUInt64ArrayTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccUInt64ArrayTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.Data.SequenceEqual(entry.Data);
+ return true;
}
- return false;
+ return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
- ///
- public bool Equals(IccUInt64ArrayTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccUInt64ArrayTagDataEntry && this.Equals((IccUInt64ArrayTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
index 13356dda6..30363df9d 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
@@ -39,21 +39,52 @@ namespace ImageSharp
///
public byte[] Data { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccUInt8ArrayTagDataEntry entry)
+ var entry = other as IccUInt8ArrayTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccUInt8ArrayTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.Data.SequenceEqual(entry.Data);
+ return true;
}
- return false;
+ return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
- ///
- public bool Equals(IccUInt8ArrayTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccUInt8ArrayTagDataEntry && this.Equals((IccUInt8ArrayTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
index b5de0f10a..e668e5cfd 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
@@ -59,23 +59,59 @@ namespace ImageSharp
///
public string Description { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccUcrBgTagDataEntry entry)
+ var entry = other as IccUcrBgTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccUcrBgTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.Description == entry.Description
- && this.UcrCurve.SequenceEqual(entry.UcrCurve)
- && this.BgCurve.SequenceEqual(entry.BgCurve);
+ return true;
}
- return false;
+ return base.Equals(other)
+ && this.UcrCurve.SequenceEqual(other.UcrCurve)
+ && this.BgCurve.SequenceEqual(other.BgCurve)
+ && string.Equals(this.Description, other.Description);
}
- ///
- public bool Equals(IccUcrBgTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccUcrBgTagDataEntry && this.Equals((IccUcrBgTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ (this.UcrCurve != null ? this.UcrCurve.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.BgCurve != null ? this.BgCurve.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.Description != null ? this.Description.GetHashCode() : 0);
+ return hashCode;
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
index 02726b600..79549b7c8 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
@@ -39,21 +39,52 @@ namespace ImageSharp
///
public byte[] Data { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccUnknownTagDataEntry entry)
+ var entry = other as IccUnknownTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccUnknownTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.Data.SequenceEqual(entry.Data);
+ return true;
}
- return false;
+ return base.Equals(other) && this.Data.SequenceEqual(other.Data);
}
- ///
- public bool Equals(IccUnknownTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccUnknownTagDataEntry && this.Equals((IccUnknownTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
index a1a65ed48..5f7406ef1 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
@@ -54,23 +54,59 @@ namespace ImageSharp
///
public IccStandardIlluminant Illuminant { get; }
- ///
+ ///
public override bool Equals(IccTagDataEntry other)
{
- if (base.Equals(other) && other is IccViewingConditionsTagDataEntry entry)
+ var entry = other as IccViewingConditionsTagDataEntry;
+ return entry != null && this.Equals(entry);
+ }
+
+ ///
+ public bool Equals(IccViewingConditionsTagDataEntry other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
{
- return this.IlluminantXyz == entry.IlluminantXyz
- && this.SurroundXyz == entry.SurroundXyz
- && this.Illuminant == entry.Illuminant;
+ return true;
}
- return false;
+ return base.Equals(other)
+ && this.IlluminantXyz.Equals(other.IlluminantXyz)
+ && this.SurroundXyz.Equals(other.SurroundXyz)
+ && this.Illuminant == other.Illuminant;
}
- ///
- public bool Equals(IccViewingConditionsTagDataEntry other)
+ ///
+ public override bool Equals(object obj)
{
- return this.Equals((IccTagDataEntry)other);
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccViewingConditionsTagDataEntry && this.Equals((IccViewingConditionsTagDataEntry)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = base.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.IlluminantXyz.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.SurroundXyz.GetHashCode();
+ hashCode = (hashCode * 397) ^ (int)this.Illuminant;
+ return hashCode;
+ }
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
index a6a3afa4e..d527d4052 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
@@ -42,7 +42,7 @@ namespace ImageSharp
Guard.NotNull(values, nameof(values));
Guard.NotNull(gridPointCount, nameof(gridPointCount));
- const float max = ushort.MaxValue;
+ const float Max = ushort.MaxValue;
this.Values = new float[values.Length][];
for (int i = 0; i < values.Length; i++)
@@ -50,7 +50,7 @@ namespace ImageSharp
this.Values[i] = new float[values[i].Length];
for (int j = 0; j < values[i].Length; j++)
{
- this.Values[i][j] = values[i][j] / max;
+ this.Values[i][j] = values[i][j] / Max;
}
}
@@ -71,7 +71,7 @@ namespace ImageSharp
Guard.NotNull(values, nameof(values));
Guard.NotNull(gridPointCount, nameof(gridPointCount));
- const float max = byte.MaxValue;
+ const float Max = byte.MaxValue;
this.Values = new float[values.Length][];
for (int i = 0; i < values.Length; i++)
@@ -79,7 +79,7 @@ namespace ImageSharp
this.Values[i] = new float[values[i].Length];
for (int j = 0; j < values[i].Length; j++)
{
- this.Values[i][j] = values[i][j] / max;
+ this.Values[i][j] = values[i][j] / Max;
}
}
@@ -118,7 +118,7 @@ namespace ImageSharp
///
public bool Equals(IccClut other)
{
- if (other == null)
+ if (ReferenceEquals(null, other))
{
return false;
}
@@ -128,11 +128,41 @@ namespace ImageSharp
return true;
}
- return this.DataType == other.DataType
+ return this.EqualsValuesArray(other)
+ && this.DataType == other.DataType
&& this.InputChannelCount == other.InputChannelCount
&& this.OutputChannelCount == other.OutputChannelCount
- && this.GridPointCount.SequenceEqual(other.GridPointCount)
- && this.EqualsValuesArray(other);
+ && this.GridPointCount.SequenceEqual(other.GridPointCount);
+ }
+
+ ///
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccClut && this.Equals((IccClut)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = this.Values != null ? this.Values.GetHashCode() : 0;
+ hashCode = (hashCode * 397) ^ (int)this.DataType;
+ hashCode = (hashCode * 397) ^ this.InputChannelCount;
+ hashCode = (hashCode * 397) ^ this.OutputChannelCount;
+ hashCode = (hashCode * 397) ^ (this.GridPointCount != null ? this.GridPointCount.GetHashCode() : 0);
+ return hashCode;
+ }
}
private bool EqualsValuesArray(IccClut other)
@@ -172,4 +202,4 @@ namespace ImageSharp
Guard.IsTrue(this.Values.Length == length, nameof(this.Values), "Length of values array does not match the grid points");
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
index dc5c7c1aa..4f744631d 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
@@ -71,9 +71,14 @@ namespace ImageSharp
///
public IccLocalizedString[] DeviceModelInfo { get; }
- ///
+ ///
public bool Equals(IccProfileDescription other)
{
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
if (ReferenceEquals(this, other))
{
return true;
@@ -86,5 +91,36 @@ namespace ImageSharp
&& this.DeviceManufacturerInfo.SequenceEqual(other.DeviceManufacturerInfo)
&& this.DeviceModelInfo.SequenceEqual(other.DeviceModelInfo);
}
+
+ ///
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccProfileDescription && this.Equals((IccProfileDescription)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = (int)this.DeviceManufacturer;
+ hashCode = (hashCode * 397) ^ (int)this.DeviceModel;
+ hashCode = (hashCode * 397) ^ this.DeviceAttributes.GetHashCode();
+ hashCode = (hashCode * 397) ^ (int)this.TechnologyInformation;
+ hashCode = (hashCode * 397) ^ (this.DeviceManufacturerInfo != null ? this.DeviceManufacturerInfo.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.DeviceModelInfo != null ? this.DeviceModelInfo.GetHashCode() : 0);
+ return hashCode;
+ }
+ }
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
index c6d8519fc..65507bf6b 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
@@ -39,13 +39,42 @@ namespace ImageSharp
///
public bool Equals(IccProfileSequenceIdentifier other)
{
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
if (ReferenceEquals(this, other))
{
return true;
}
- return this.Id.Equals(other.Id)
- && this.Description.SequenceEqual(other.Description);
+ return this.Id.Equals(other.Id) && this.Description.SequenceEqual(other.Description);
+ }
+
+ ///
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is IccProfileSequenceIdentifier && this.Equals((IccProfileSequenceIdentifier)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (this.Id.GetHashCode() * 397) ^ (this.Description != null ? this.Description.GetHashCode() : 0);
+ }
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs
index 40eab6ef4..ac0e89bb0 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs
@@ -70,18 +70,18 @@ namespace ImageSharp
return !left.Equals(right);
}
- ///
- public override bool Equals(object other)
+ ///
+ public bool Equals(IccScreeningChannel other)
{
- return (other is IccScreeningChannel) && this.Equals((IccScreeningChannel)other);
+ return this.Frequency.Equals(other.Frequency)
+ && this.Angle.Equals(other.Angle)
+ && this.SpotShape == other.SpotShape;
}
///
- public bool Equals(IccScreeningChannel other)
+ public override bool Equals(object obj)
{
- return this.Frequency == other.Frequency
- && this.Angle == other.Angle
- && this.SpotShape == other.SpotShape;
+ return obj is IccScreeningChannel && this.Equals((IccScreeningChannel)obj);
}
///
@@ -91,7 +91,7 @@ namespace ImageSharp
{
int hashCode = this.Frequency.GetHashCode();
hashCode = (hashCode * 397) ^ this.Angle.GetHashCode();
- hashCode = (hashCode * 397) ^ this.SpotShape.GetHashCode();
+ hashCode = (hashCode * 397) ^ (int)this.SpotShape;
return hashCode;
}
}
@@ -102,4 +102,4 @@ namespace ImageSharp
return $"{this.Frequency}Hz; {this.Angle}°; {this.SpotShape}";
}
}
-}
+}
\ No newline at end of file