Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement IEquatable<T> #126

Merged
merged 1 commit into from Jan 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion Splat/Points/Point.cs
Expand Up @@ -39,6 +39,7 @@
namespace System.Drawing
{
public struct Point
: IEquatable<Point>
{
// Private x and y coordinate fields.
private int x, y;
Expand Down Expand Up @@ -317,6 +318,19 @@ public int Y
}
}

/// <summary>
/// Equals Method
/// </summary>
///
/// <remarks>
/// Checks equivalence of this Point and another Point.
/// </remarks>

public bool Equals(Point other)
{
return ((this.X == other.X) && (this.Y == other.Y));
}

/// <summary>
/// Equals Method
/// </summary>
Expand All @@ -330,7 +344,7 @@ public override bool Equals(object obj)
if (!(obj is Point))
return false;

return (this == (Point)obj);
return this.Equals((Point)obj);
}

/// <summary>
Expand Down
16 changes: 15 additions & 1 deletion Splat/Points/PointF.cs
Expand Up @@ -35,6 +35,7 @@
namespace System.Drawing
{
public struct PointF
: IEquatable<PointF>
{
// Private x and y coordinate fields.
private float x, y;
Expand Down Expand Up @@ -201,6 +202,19 @@ public float Y
}
}

/// <summary>
/// Equals Method
/// </summary>
///
/// <remarks>
/// Checks equivalence of this PointF and another PointF.
/// </remarks>

public bool Equals(PointF other)
{
return ((this.X == other.X) && (this.Y == other.Y));
}

/// <summary>
/// Equals Method
/// </summary>
Expand All @@ -214,7 +228,7 @@ public override bool Equals(object obj)
if (!(obj is PointF))
return false;

return (this == (PointF)obj);
return this.Equals((PointF)obj);
}

/// <summary>
Expand Down
17 changes: 16 additions & 1 deletion Splat/Points/Rectangle.cs
Expand Up @@ -38,6 +38,7 @@
namespace System.Drawing
{
public struct Rectangle
: IEquatable<Rectangle>
{
private int x, y, width, height;

Expand Down Expand Up @@ -564,6 +565,20 @@ public bool Contains(Rectangle rect)
return (rect == Intersect(this, rect));
}

/// <summary>
/// Equals Method
/// </summary>
///
/// <remarks>
/// Checks equivalence of this Rectangle and another Rectangle.
/// </remarks>

public bool Equals(Rectangle other)
{
return ((this.Location == other.Location) &&
(this.Size == other.Size));
}

/// <summary>
/// Equals Method
/// </summary>
Expand All @@ -577,7 +592,7 @@ public override bool Equals(object obj)
if (!(obj is Rectangle))
return false;

return (this == (Rectangle)obj);
return this.Equals((Rectangle)obj);
}

/// <summary>
Expand Down
17 changes: 16 additions & 1 deletion Splat/Points/RectangleF.cs
Expand Up @@ -33,6 +33,7 @@
namespace System.Drawing
{
public struct RectangleF
: IEquatable<RectangleF>
{
private float x, y, width, height;

Expand Down Expand Up @@ -510,6 +511,20 @@ public bool Contains(RectangleF rect)
return (rect == Intersect(this, rect));
}

/// <summary>
/// Equals Method
/// </summary>
///
/// <remarks>
/// Checks equivalence of this RectangleF and an RectangleF.
/// </remarks>

public bool Equals(RectangleF other)
{
return ((this.Location == other.Location) &&
(this.Size == other.Size));
}

/// <summary>
/// Equals Method
/// </summary>
Expand All @@ -523,7 +538,7 @@ public override bool Equals(object obj)
if (!(obj is RectangleF))
return false;

return (this == (RectangleF)obj);
return this.Equals((RectangleF)obj);
}

/// <summary>
Expand Down
17 changes: 16 additions & 1 deletion Splat/Points/Size.cs
Expand Up @@ -39,6 +39,7 @@
namespace System.Drawing
{
public struct Size
: IEquatable<Size>
{

// Private Height and width fields.
Expand Down Expand Up @@ -302,6 +303,20 @@ public int Height
}
}

/// <summary>
/// Equals Method
/// </summary>
///
/// <remarks>
/// Checks equivalence of this Size and another Size.
/// </remarks>

public bool Equals(Size other)
{
return ((this.Width == other.Width) &&
(this.Height == other.Height));
}

/// <summary>
/// Equals Method
/// </summary>
Expand All @@ -315,7 +330,7 @@ public override bool Equals(object obj)
if (!(obj is Size))
return false;

return (this == (Size)obj);
return this.Equals((Size)obj);
}

/// <summary>
Expand Down
17 changes: 16 additions & 1 deletion Splat/Points/SizeF.cs
Expand Up @@ -39,6 +39,7 @@
namespace System.Drawing
{
public struct SizeF
: IEquatable<SizeF>
{
// Private height and width fields.
private float width, height;
Expand Down Expand Up @@ -238,6 +239,20 @@ public float Height
}
}

/// <summary>
/// Equals Method
/// </summary>
///
/// <remarks>
/// Checks equivalence of this SizeF and another SizeF.
/// </remarks>

public bool Equals(SizeF other)
{
return ((this.Width == other.Width) &&
(this.Height == other.Height));
}

/// <summary>
/// Equals Method
/// </summary>
Expand All @@ -251,7 +266,7 @@ public override bool Equals(object obj)
if (!(obj is SizeF))
return false;

return (this == (SizeF)obj);
return this.Equals((SizeF)obj);
}

/// <summary>
Expand Down