Browse Source

Simplify Equals override

af/merge-core
Jason Nelson 8 years ago
parent
commit
b1f6af6b0d
  1. 7
      src/ImageSharp/ColorSpaces/CieLch.cs
  2. 7
      src/ImageSharp/ColorSpaces/CieLchuv.cs
  3. 7
      src/ImageSharp/ColorSpaces/CieLuv.cs
  4. 7
      src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs
  5. 7
      src/ImageSharp/ColorSpaces/CieXyy.cs
  6. 7
      src/ImageSharp/ColorSpaces/CieXyz.cs
  7. 7
      src/ImageSharp/ColorSpaces/Cmyk.cs
  8. 9
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/RGBPrimariesChromaticityCoordinates.cs
  9. 7
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/RgbWorkingSpace.cs
  10. 7
      src/ImageSharp/ColorSpaces/Hsl.cs
  11. 7
      src/ImageSharp/ColorSpaces/Hsv.cs
  12. 7
      src/ImageSharp/ColorSpaces/HunterLab.cs
  13. 7
      src/ImageSharp/ColorSpaces/LinearRgb.cs
  14. 7
      src/ImageSharp/ColorSpaces/Lms.cs
  15. 7
      src/ImageSharp/ColorSpaces/Rgb.cs
  16. 7
      src/ImageSharp/ColorSpaces/YCbCr.cs
  17. 4
      src/ImageSharp/Formats/Gif/PackedField.cs
  18. 7
      src/ImageSharp/Formats/Jpeg/Common/Block8x8.cs
  19. 7
      src/ImageSharp/Formats/Jpeg/Common/Decoder/AdobeMarker.cs
  20. 9
      src/ImageSharp/Formats/Jpeg/Common/Decoder/JFifMarker.cs
  21. 4
      src/ImageSharp/MetaData/ImageProperty.cs
  22. 28
      src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs
  23. 2
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs
  24. 2
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
  25. 2
      src/ImageSharp/PixelFormats/Alpha8.cs
  26. 2
      src/ImageSharp/PixelFormats/Bgr24.cs
  27. 2
      src/ImageSharp/PixelFormats/Bgra32.cs
  28. 2
      src/ImageSharp/PixelFormats/Bgra4444.cs
  29. 2
      src/ImageSharp/PixelFormats/Bgra5551.cs
  30. 2
      src/ImageSharp/PixelFormats/HalfVector4.cs
  31. 2
      src/ImageSharp/PixelFormats/NormalizedByte2.cs
  32. 2
      src/ImageSharp/PixelFormats/NormalizedByte4.cs
  33. 2
      src/ImageSharp/PixelFormats/NormalizedShort4.cs
  34. 2
      src/ImageSharp/PixelFormats/Rgb24.cs
  35. 2
      src/ImageSharp/PixelFormats/RgbaVector.cs
  36. 2
      src/ImageSharp/PixelFormats/Short2.cs
  37. 2
      src/ImageSharp/PixelFormats/Short4.cs
  38. 2
      src/ImageSharp/Primitives/DenseMatrix{T}.cs

7
src/ImageSharp/ColorSpaces/CieLch.cs

@ -194,12 +194,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is CieLch)
{
return this.Equals((CieLch)obj);
}
return false;
return obj is CieLch other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/ColorSpaces/CieLchuv.cs

@ -194,12 +194,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is CieLchuv)
{
return this.Equals((CieLchuv)obj);
}
return false;
return obj is CieLchuv other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/ColorSpaces/CieLuv.cs

@ -196,12 +196,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is CieLuv)
{
return this.Equals((CieLuv)obj);
}
return false;
return obj is CieLuv other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs

@ -132,12 +132,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is CieXyChromaticityCoordinates)
{
return this.Equals((CieXyChromaticityCoordinates)obj);
}
return false;
return obj is CieXyChromaticityCoordinates other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/ColorSpaces/CieXyy.cs

@ -148,12 +148,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is CieXyy)
{
return this.Equals((CieXyy)obj);
}
return false;
return obj is CieXyy other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/ColorSpaces/CieXyz.cs

@ -148,12 +148,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is CieXyz)
{
return this.Equals((CieXyz)obj);
}
return false;
return obj is CieXyz other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/ColorSpaces/Cmyk.cs

@ -150,12 +150,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is Cmyk)
{
return this.Equals((Cmyk)obj);
}
return false;
return obj is Cmyk other && this.Equals(other);
}
/// <inheritdoc/>

9
src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/RGBPrimariesChromaticityCoordinates.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSap
/// Represents the chromaticity coordinates of RGB primaries.
/// One of the specifiers of <see cref="IRgbWorkingSpace"/>.
/// </summary>
internal struct RgbPrimariesChromaticityCoordinates : IEquatable<RgbPrimariesChromaticityCoordinates>
internal readonly struct RgbPrimariesChromaticityCoordinates : IEquatable<RgbPrimariesChromaticityCoordinates>
{
/// <summary>
/// Initializes a new instance of the <see cref="RgbPrimariesChromaticityCoordinates"/> struct.
@ -76,12 +76,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSap
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (obj is RgbPrimariesChromaticityCoordinates)
{
return this.Equals((RgbPrimariesChromaticityCoordinates)obj);
}
return false;
return obj is RgbPrimariesChromaticityCoordinates other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/RgbWorkingSpace.cs

@ -73,12 +73,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSap
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (obj is RgbWorkingSpace)
{
return this.Equals((RgbWorkingSpace)obj);
}
return false;
return obj is RgbWorkingSpace other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/ColorSpaces/Hsl.cs

@ -150,12 +150,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is Hsl)
{
return this.Equals((Hsl)obj);
}
return false;
return obj is Hsl other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/ColorSpaces/Hsv.cs

@ -202,12 +202,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is Hsv)
{
return this.Equals((Hsv)obj);
}
return false;
return obj is Hsv other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/ColorSpaces/HunterLab.cs

@ -190,12 +190,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is HunterLab)
{
return this.Equals((HunterLab)obj);
}
return false;
return obj is HunterLab other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/ColorSpaces/LinearRgb.cs

@ -182,12 +182,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is LinearRgb)
{
return this.Equals((LinearRgb)obj);
}
return false;
return obj is LinearRgb other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/ColorSpaces/Lms.cs

@ -149,12 +149,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is Lms)
{
return this.Equals((Lms)obj);
}
return false;
return obj is Lms other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/ColorSpaces/Rgb.cs

@ -204,12 +204,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is Rgb)
{
return this.Equals((Rgb)obj);
}
return false;
return obj is Rgb other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/ColorSpaces/YCbCr.cs

@ -152,12 +152,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is YCbCr)
{
return this.Equals((YCbCr)obj);
}
return false;
return obj is YCbCr other && this.Equals(other);
}
/// <inheritdoc/>

4
src/ImageSharp/Formats/Gif/PackedField.cs

@ -169,9 +169,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <inheritdoc/>
public override bool Equals(object obj)
{
PackedField? field = obj as PackedField?;
return this.Byte == field?.Byte;
return obj is PackedField other && this.Equals(other);
}
/// <inheritdoc/>

7
src/ImageSharp/Formats/Jpeg/Common/Block8x8.cs

@ -273,12 +273,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common
/// <inheritdoc />
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
return obj is Block8x8 && this.Equals((Block8x8)obj);
return obj is Block8x8 other && this.Equals(other);
}
/// <inheritdoc />

7
src/ImageSharp/Formats/Jpeg/Common/Decoder/AdobeMarker.cs

@ -94,12 +94,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
return obj is AdobeMarker && this.Equals((AdobeMarker)obj);
return obj is AdobeMarker other && this.Equals(other);
}
/// <inheritdoc/>

9
src/ImageSharp/Formats/Jpeg/Common/Decoder/JFifMarker.cs

@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder
}
}
marker = default(JFifMarker);
marker = default;
return false;
}
@ -104,12 +104,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
return obj is JFifMarker && this.Equals((JFifMarker)obj);
return obj is JFifMarker other && this.Equals(other);
}
/// <inheritdoc/>

4
src/ImageSharp/MetaData/ImageProperty.cs

@ -110,9 +110,7 @@ namespace SixLabors.ImageSharp.MetaData
/// </returns>
public override bool Equals(object obj)
{
ImageProperty other = obj as ImageProperty;
return this.Equals(other);
return obj is ImageProperty other && Equals(other);
}
/// <summary>

28
src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs

@ -77,37 +77,24 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
/// <summary>
/// Gets the data type of the exif value.
/// </summary>
public ExifDataType DataType
{
get;
}
public ExifDataType DataType { get; }
/// <summary>
/// Gets a value indicating whether the value is an array.
/// </summary>
public bool IsArray
{
get;
}
public bool IsArray { get; }
/// <summary>
/// Gets the tag of the exif value.
/// </summary>
public ExifTag Tag
{
get;
}
public ExifTag Tag { get; }
/// <summary>
/// Gets or sets the value.
/// </summary>
public object Value
{
get
{
return this.exifValue;
}
get => this.exifValue;
set
{
this.CheckValue(value);
@ -217,12 +204,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
/// <inheritdoc />
public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj))
{
return true;
}
return this.Equals(obj as ExifValue);
return obj is ExifValue other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs

@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
return obj is IccParametricCurve && this.Equals((IccParametricCurve)obj);
return obj is IccParametricCurve other && this.Equals(other);
}
/// <inheritdoc/>

2
src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs

@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
return obj is IccResponseCurve && this.Equals((IccResponseCurve)obj);
return obj is IccResponseCurve other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/PixelFormats/Alpha8.cs

@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <returns>True if the object is equal to the packed vector.</returns>
public override bool Equals(object obj)
{
return (obj is Alpha8) && this.Equals((Alpha8)obj);
return obj is Alpha8 other && this.Equals(other);
}
/// <summary>

2
src/ImageSharp/PixelFormats/Bgr24.cs

@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
public override bool Equals(object obj)
{
return obj?.GetType() == typeof(Bgr24) && this.Equals((Bgr24)obj);
return obj is Bgr24 other && this.Equals(other);
}
/// <inheritdoc/>

2
src/ImageSharp/PixelFormats/Bgra32.cs

@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj?.GetType() == typeof(Bgra32) && this.Equals((Bgra32)obj);
public override bool Equals(object obj) => obj is Bgra32 other && this.Equals(other);
/// <inheritdoc/>
public override int GetHashCode()

2
src/ImageSharp/PixelFormats/Bgra4444.cs

@ -142,7 +142,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override bool Equals(object obj)
{
return (obj is Bgra4444) && this.Equals((Bgra4444)obj);
return obj is Bgra4444 other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/PixelFormats/Bgra5551.cs

@ -142,7 +142,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override bool Equals(object obj)
{
return (obj is Bgra5551) && this.Equals((Bgra5551)obj);
return obj is Bgra5551 other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/PixelFormats/HalfVector4.cs

@ -172,7 +172,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override bool Equals(object obj)
{
return (obj is HalfVector4) && this.Equals((HalfVector4)obj);
return obj is HalfVector4 other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/PixelFormats/NormalizedByte2.cs

@ -175,7 +175,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override bool Equals(object obj)
{
return (obj is NormalizedByte2) && this.Equals((NormalizedByte2)obj);
return obj is NormalizedByte2 other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/PixelFormats/NormalizedByte4.cs

@ -168,7 +168,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override bool Equals(object obj)
{
return (obj is NormalizedByte4) && this.Equals((NormalizedByte4)obj);
return obj is NormalizedByte4 other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/PixelFormats/NormalizedShort4.cs

@ -170,7 +170,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override bool Equals(object obj)
{
return (obj is NormalizedShort4) && this.Equals((NormalizedShort4)obj);
return obj is NormalizedShort4 other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/PixelFormats/Rgb24.cs

@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
public override bool Equals(object obj)
{
return obj?.GetType() == typeof(Rgb24) && this.Equals((Rgb24)obj);
return obj is Rgb24 other && this.Equals(other);
}
/// <inheritdoc/>

2
src/ImageSharp/PixelFormats/RgbaVector.cs

@ -290,7 +290,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
public override bool Equals(object obj)
{
return (obj is RgbaVector) && this.Equals((RgbaVector)obj);
return obj is RgbaVector other && this.Equals(other);
}
/// <inheritdoc/>

2
src/ImageSharp/PixelFormats/Short2.cs

@ -171,7 +171,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override bool Equals(object obj)
{
return (obj is Short2) && this.Equals((Short2)obj);
return obj is Short2 other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/PixelFormats/Short4.cs

@ -166,7 +166,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override bool Equals(object obj)
{
return (obj is Short4) && this == (Short4)obj;
return obj is Short4 other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/Primitives/DenseMatrix{T}.cs

@ -207,7 +207,7 @@ namespace SixLabors.ImageSharp.Primitives
}
/// <inheritdoc/>
public override bool Equals(object obj) => obj is DenseMatrix<T> matrix && this.Equals(matrix);
public override bool Equals(object obj) => obj is DenseMatrix<T> other && this.Equals(other);
/// <inheritdoc/>
public override int GetHashCode() => this.Data.GetHashCode();

Loading…
Cancel
Save