mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-07 23:45:05 +00:00
Equality methods
This commit is contained in:
parent
23a8e49efb
commit
2686cda333
9 changed files with 47 additions and 91 deletions
|
|
@ -1,47 +1,27 @@
|
|||
namespace MapControl
|
||||
using System;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Replaces Windows.Foundation.Point for double floating point precision.
|
||||
/// </summary>
|
||||
public readonly struct Point
|
||||
public readonly struct Point(double x, double y) : IEquatable<Point>
|
||||
{
|
||||
public Point(double x, double y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
public double X => x;
|
||||
public double Y => y;
|
||||
|
||||
public double X { get; }
|
||||
public double Y { get; }
|
||||
public static implicit operator Windows.Foundation.Point(Point p) => new(p.X, p.Y);
|
||||
|
||||
public static implicit operator Windows.Foundation.Point(Point p)
|
||||
{
|
||||
return new Windows.Foundation.Point(p.X, p.Y);
|
||||
}
|
||||
public static implicit operator Point(Windows.Foundation.Point p) => new(p.X, p.Y);
|
||||
|
||||
public static implicit operator Point(Windows.Foundation.Point p)
|
||||
{
|
||||
return new Point(p.X, p.Y);
|
||||
}
|
||||
public static bool operator ==(Point p1, Point p2) => p1.Equals(p2);
|
||||
|
||||
public static bool operator ==(Point p1, Point p2)
|
||||
{
|
||||
return p1.X == p2.X && p1.Y == p2.Y;
|
||||
}
|
||||
public static bool operator !=(Point p1, Point p2) => !p1.Equals(p2);
|
||||
|
||||
public static bool operator !=(Point p1, Point p2)
|
||||
{
|
||||
return !(p1 == p2);
|
||||
}
|
||||
public bool Equals(Point p) => X == p.X && Y == p.Y;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is Point p && this == p;
|
||||
}
|
||||
public override bool Equals(object obj) => obj is Point p && Equals(p);
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return X.GetHashCode() ^ Y.GetHashCode();
|
||||
}
|
||||
public override int GetHashCode() => X.GetHashCode() ^ Y.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue