public void ReadMultilineBufferedSkip() { var Buffer = new char[4]; using (var Reader = new BinaryTextReader(_TestMultilineInput, Encoding.UTF8, false, 4)) { while (!Reader.EndOfReader) { if (!Reader.TryReadLine(Buffer, out var CharsWritten)) { Reader.SkipLine(); } } } }
public void TempTest() { using var RawEventFile = File.Open(@"C:\Development\Resources\Zenith\Events 134.log", FileMode.Open); using var RawReader = new StreamBufferReader(RawEventFile); using var EventReader = new BinaryTextReader(RawReader); var EventBuffer = new char[128]; var TotalRecords = 0; var LastSequenceNumber = 1L; var TimeStamp = DateTimeOffset.MinValue; var IsStatus = false; while (!EventReader.EndOfReader) { var Offset = 0; // Decode the start of the next line into the buffer. It should be more than sufficiently large for the header if (!EventReader.TryReadLine(EventBuffer.AsSpan(Offset), out var CharsWritten)) { EventReader.SkipLine(); // We don't need the rest of the line data, no sense copying it } var Line = EventBuffer.AsSpan(0, CharsWritten); if (Line.IsEmpty) { continue; } // Find the first SequenceNumber:DateTimeUtc:Type:Data divider var Divider = Line.IndexOf(':'); if (Divider == -1) { continue; } // Process the sequence number if (!long.TryParse(Line.Slice(0, Divider), NumberStyles.None, CultureInfo.InvariantCulture, out var SequenceNumber)) { continue; } TotalRecords++; LastSequenceNumber = SequenceNumber; IsStatus = false; // Find the next divider (end of DateTimeUtc) var NextDivider = Line.Slice(++Divider).IndexOf(':'); if (NextDivider == -1) { continue; } if (!DateTimeOffset.TryParseExact(Line.Slice(Divider, NextDivider), "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture, DateTimeStyles.None, out var NewTimeStamp)) { continue; } TimeStamp = NewTimeStamp; Divider += NextDivider + 1; // Next divider (end of Type) NextDivider = Line.Slice(Divider).IndexOf(':'); var Type = Line.Slice(Divider, NextDivider); // Check if it's a Status event IsStatus = Type.SequenceEqual("Status"); } }