-
Notifications
You must be signed in to change notification settings - Fork 186
Expand file tree
/
Copy pathLogLine.cs
More file actions
40 lines (35 loc) · 1.7 KB
/
LogLine.cs
File metadata and controls
40 lines (35 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
namespace ColumnizerLib;
/// <summary>
/// Represents a single log line, including its full text and line number.
/// </summary>
/// <remarks>
/// <para> <b> Purpose:</b> <br/> The <c> LogLine</c> struct encapsulates the content and line number of a log entry. It
/// is used throughout the columnizer and log processing infrastructure to provide a strongly-typed, immutable
/// representation of a log line. </para>
/// <para> <b> Usage:</b> <br/> This struct implements the
/// <see cref="ILogLineMemory"/> interface, allowing it to be used wherever an <c> ILogLineMemory</c> is expected. It
/// provides value semantics and is intended to be lightweight and efficiently passed by value. </para> <para> <b>
/// Relationship to ILogLineMemory:</b> <br/> <c> LogLine</c> is a concrete, immutable implementation of the
/// <see cref="ILogLineMemory"/> interface, providing properties for the full line text and its line number. </para>
/// This is a readonly record struct implementing
/// <see cref="ILogLineMemory"/>. Stored inline in <c> List<LogLine></c> to avoid boxing and heap allocation.
/// Boxing occurs only when returned through the <c> ILogLineMemory</c> interface boundary.
/// </remarks>
public readonly record struct LogLine : ILogLineMemory
{
public int LineNumber { get; }
public ReadOnlyMemory<char> FullLine { get; }
public ReadOnlyMemory<char> Text { get; }
public LogLine (string fullLine, int lineNumber)
{
LineNumber = lineNumber;
FullLine = fullLine.AsMemory();
Text = fullLine.AsMemory();
}
public LogLine (ReadOnlyMemory<char> fullLine, int lineNumber)
{
LineNumber = lineNumber;
FullLine = fullLine;
Text = fullLine;
}
}