using System.IO; using System.Text.Json; using System.Text.Json.Serialization; using System.Threading.Tasks; namespace FileExposer.Models; public record RelativePath(string LeftDirectory, string? RightDirectory, Record[] Records) { internal static RelativePath? Get(Stream stream) { RelativePath? result; string? json = GetJson(stream); result = string.IsNullOrEmpty(json) ? null : JsonSerializer.Deserialize(json); return result; } private static string? GetJson(Stream stream) { string? result; if (!stream.CanRead) result = null; else { Task task = new StreamReader(stream).ReadToEndAsync(); result = task.Result; } return result; } } [JsonSourceGenerationOptions(WriteIndented = true)] [JsonSerializable(typeof(RelativePath))] public partial class RelativePathSourceGenerationContext : JsonSerializerContext { }