FaceFile for D2

This commit is contained in:
2024-10-20 17:49:48 -07:00
parent 7b00fcaae8
commit 924bd14c31
12 changed files with 261 additions and 0 deletions

42
Shared/Models/Location.cs Normal file
View File

@ -0,0 +1,42 @@
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
[method: JsonConstructor]
public class Location(int bottom, double confidence, int left, int right, int top) : Properties.ILocation, IEquatable<Location>
{
public int Bottom { init; get; } = bottom;
public double Confidence { init; get; } = confidence;
public int Left { init; get; } = left;
public int Right { init; get; } = right;
public int Top { init; get; } = top;
public override bool Equals(object? obj) => Equals(obj as Location);
#pragma warning disable IDE0070
public override int GetHashCode()
#pragma warning restore IDE0070
{
int hashCode = -773114317;
hashCode = (hashCode * -1521134295) + Bottom.GetHashCode();
hashCode = (hashCode * -1521134295) + Left.GetHashCode();
hashCode = (hashCode * -1521134295) + Right.GetHashCode();
hashCode = (hashCode * -1521134295) + Top.GetHashCode();
return hashCode;
}
public bool Equals(Location? location)
{
return location is not null
&& Bottom == location.Bottom
&& Left == location.Left
&& Right == location.Right
&& Top == location.Top;
}
public static bool operator ==(Location location1, Location location2) => EqualityComparer<Location>.Default.Equals(location1, location2);
public static bool operator !=(Location location1, Location location2) => !(location1 == location2);
}