52 lines
1.4 KiB
C#
52 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Adaptation.FileHandlers.pcl;
|
|
|
|
#nullable enable
|
|
|
|
internal class Complete
|
|
{
|
|
|
|
public Complete(Header header, Summary summary, ReadOnlyCollection<Point> points)
|
|
{
|
|
Header = header;
|
|
Summary = summary;
|
|
Points = points;
|
|
}
|
|
|
|
public Header Header { get; }
|
|
public Summary Summary { get; }
|
|
public ReadOnlyCollection<Point> Points { get; }
|
|
|
|
public static Complete? Get(Constant constant, ReadOnlyCollection<string> lines)
|
|
{
|
|
Complete? result;
|
|
Header? header = Header.Get(constant, lines);
|
|
if (header is null)
|
|
result = null;
|
|
else
|
|
{
|
|
Summary? summary = SummarySegment.Get(constant, lines);
|
|
if (summary is null)
|
|
result = null;
|
|
else
|
|
{
|
|
ReadOnlyCollection<Point> points = Point.GetCollection(constant, lines) ?? throw new NullReferenceException(nameof(summary));
|
|
if (points.Count == 0)
|
|
result = null;
|
|
else
|
|
result = new(header, summary, points);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Complete))]
|
|
internal partial class CompleteSourceGenerationContext : JsonSerializerContext
|
|
{
|
|
} |