using System.Text.Json; using System.Text.Json.Serialization; namespace View_by_Distance.Shared.Models; public class RelativeLocation : Properties.IRelativeLocation { public double Confidence { init; get; } public string Height { init; get; } public string Left { init; get; } public string Top { init; get; } public string Width { init; get; } [JsonConstructor] public RelativeLocation(double confidence, string height, string left, string top, string width) { Confidence = confidence; Height = height; Left = left; Top = top; Width = width; } public bool Match(decimal? height, decimal? left, decimal? top, decimal? width) { bool result; if (height is null || left is null || top is null || width is null) result = false; else if (height.Value.ToString() == Height && left.Value.ToString() == Left && top.Value.ToString() == Top && width.Value.ToString() == Width) result = false; else result = true; return result; } public override string ToString() { string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); return result; } }