using System.Text.Json;
using System.Text.Json.Serialization;

namespace View_by_Distance.Shared.Models;

public class DistanceHolder : Properties.IDistanceHolder
{

    public Face Face { init; get; }
    public FileHolder FileHolder { init; get; }
    public int Id { init; get; }
    public string JSONDirectory { init; get; }
    public Location? Location { init; get; }
    public string TSVDirectory { init; get; }
    public double Sort { get; set; }

    [JsonConstructor]
    public DistanceHolder(
        Face face,
        FileHolder fileHolder,
        int id,
        string jsonDirectory,
        Location? location,
        string tsvDirectory
    )
    {
        FileHolder = fileHolder;
        Sort = double.MaxValue;
        Face = face;
        Id = id;
        JSONDirectory = jsonDirectory;
        Location = location;
        TSVDirectory = tsvDirectory;
    }

    public override string ToString()
    {
        string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
        return result;
    }

}