Oakrey.Readers
5.0.0
dotnet add package Oakrey.Readers --version 5.0.0
NuGet\Install-Package Oakrey.Readers -Version 5.0.0
<PackageReference Include="Oakrey.Readers" Version="5.0.0" />
<PackageVersion Include="Oakrey.Readers" Version="5.0.0" />
<PackageReference Include="Oakrey.Readers" />
paket add Oakrey.Readers --version 5.0.0
#r "nuget: Oakrey.Readers, 5.0.0"
#:package Oakrey.Readers@5.0.0
#addin nuget:?package=Oakrey.Readers&version=5.0.0
#tool nuget:?package=Oakrey.Readers&version=5.0.0
Oakrey.Readers
Oakrey.Readers provides small, extensible helpers for reading text files line by line and representing each line as a strongly typed object.
Features
LineReader<TLine>reads text from a file, stream, orStreamReaderand creates custom line objects.Lineexposes line number, original text, trimmed text, ordinal prefix checks, and simple empty/whitespace flags.ComponentLinesplits trimmed lines into components, caches parsed values internally, and returns defensive copies.EscapeLineadds escape-character detection for component-based formats.- Helpers are designed for simple parser scenarios where line number diagnostics matter.
Installation
dotnet add package Oakrey.Readers
Package Manager Console:
Install-Package Oakrey.Readers
Basic Usage
using Oakrey.Readers;
using LineReader<Line> reader = new(new FileInfo("input.txt"));
while (reader.MoveNext())
{
Line line = reader.Current;
Console.WriteLine($"#{line.LineNumber}: {line.Text}");
}
Read a required non-empty line:
using LineReader<Line> reader = new(new FileInfo("input.txt"));
Line line = reader.NextLineNoneEmptyLine();
Skip blank lines until data is found:
using LineReader<Line> reader = new(new FileInfo("input.txt"));
Line line = reader.NextNonEmptyLine();
Custom Component Line
public sealed class CsvLikeLine(string text, int lineNumber) : ComponentLine(text, lineNumber)
{
public override StringSplitOptions Options => StringSplitOptions.RemoveEmptyEntries;
protected override char[] Separators => [',', ';'];
}
using LineReader<CsvLikeLine> reader = new(new FileInfo("input.txt"));
CsvLikeLine line = reader.NextLine();
Console.WriteLine(line.ComponentsCount);
Console.WriteLine(line[0]);
Notes
- Custom line types used with
LineReader<TLine>must expose a public constructor with(string text, int lineNumber)parameters. Reset()requires a seekable underlying stream and resets line numbering back to the first line.StartsWith(string)usesStringComparison.Ordinalby default for predictable parser behavior.
Requirements
- .NET 10 or higher
Project Information
- Author: Oakrey
- Company: Oakrey (Website)
- License: MIT
- Repository: Git Repository
- Project URL: NuGet
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Oakrey.Readers:
| Package | Downloads |
|---|---|
|
Oakrey.DBC
Oakrey.DBC is a .NET 11 library for parsing, building, and exporting DBC (CAN database) files. Provides a full object model covering messages, signals (including multiplexing, big/little endian, scale/offset), nodes, attributes, value tables, and relationships. Supports async file parsing via DbcMatrix.CreateAsync and round-trip export via SaveDBC. Designed for automotive, industrial, and IoT applications. |
|
|
Oakrey.LDF
Async parser, strongly-typed object model, and composer for LIN Description Files (LDF) per the LIN 2.x specification. Covers nodes, signals, frames, schedule tables, signal encoding types, and diagnostic elements. Supports round-trip export back to a spec-compliant LDF text file. |
GitHub repositories
This package is not used by any popular GitHub repositories.