32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
using System.Text;
|
|
|
|
namespace XNeedle
|
|
{
|
|
/// <summary>
|
|
/// Carries the origin information for a loaded XML document:
|
|
/// the file path, the detected encoding, and the line number of the
|
|
/// associated node (-1 when line information is unavailable).
|
|
/// </summary>
|
|
public struct SourceLocation
|
|
{
|
|
public string FilePath { get; set; }
|
|
public Encoding Encoding { get; set; }
|
|
/// <summary>
|
|
/// 1-based line number of the associated node, or -1 if unknown.
|
|
/// </summary>
|
|
public int LineNumber { get; set; }
|
|
|
|
public SourceLocation(string filePath, Encoding encoding, int lineNumber = -1)
|
|
{
|
|
FilePath = filePath;
|
|
Encoding = encoding;
|
|
LineNumber = lineNumber;
|
|
}
|
|
|
|
public SourceLocation WithLineNumber(int lineNumber) =>
|
|
new SourceLocation(FilePath, Encoding, lineNumber);
|
|
public SourceLocation AsSynthetic() =>
|
|
new SourceLocation("<synthetic>", Encoding, -1);
|
|
}
|
|
}
|