42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using System.Text.Json.Serialization;
|
|
|
|
namespace File_Folder_Helper.Models.Face;
|
|
|
|
[method: JsonConstructor]
|
|
public class Location(int bottom, double confidence, int left, int right, int top) : 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);
|
|
|
|
} |