namespace AdventOfCode2024.Input.Parsers; public abstract class TextLineParser : IParser> where U : notnull { /// /// Parses a line to the given Entity type /// /// Line in the form of a string /// The parsed entity protected abstract U ParseLine(string line); /// public async Task> ParseAsync(Stream input) { using StreamReader reader = new StreamReader(input); List entities = []; while (!reader.EndOfStream) { string? line = await reader.ReadLineAsync(); if (line != null) { entities.Add(ParseLine(line)); } } return entities; } }