53 lines
1.6 KiB
C#
53 lines
1.6 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(int take, string site, string multiple, string summaryLine, string lastUnits, string[] lines)
|
|
{
|
|
Complete? result;
|
|
Header? header = Header.Get(lines, site, summaryLine);
|
|
if (header is null)
|
|
result = null;
|
|
else
|
|
{
|
|
Summary? summary = SummarySegment.Get(lines, site, summaryLine);
|
|
if (summary is null)
|
|
result = null;
|
|
else
|
|
{
|
|
ReadOnlyCollection<Point> points = Point.GetCollection(lines, take, site, multiple, summaryLine, lastUnits) ?? 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
|
|
{
|
|
}
|