using System.Text.Json; using System.Text.Json.Serialization; namespace View_by_Distance.Shared.Models; public class Container : Properties.IContainer { protected readonly int _G; protected readonly int _R; protected readonly List _Items; protected readonly string _SourceDirectory; public int G => _G; public List Items => _Items; public int R => _R; public string SourceDirectory => _SourceDirectory; [JsonConstructor] public Container(int g, int r, List items, string sourceDirectory) { _G = g; _R = r; _Items = items; _SourceDirectory = sourceDirectory; } public Container(int g, int r, string sourceDirectory) { _G = g; _R = r; _Items = new(); _SourceDirectory = sourceDirectory; } public override string ToString() { string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); return result; } }