PgPath
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Owns an immutable ordered sequence of points and an open/closed flag for PostgreSQL path. Empty paths can be constructed and exchanged even though PostgreSQL’s text parser requires points.
public sealed class PgPath : IReadOnlyList<PgPoint>, IReadOnlyCollection<PgPoint>, IEnumerable<PgPoint>, IEnumerable, ISpanFormattable, IFormattable, IParsable<PgPath>Inheritance: object
Implements: IReadOnlyList<PgPoint>, IReadOnlyCollection<PgPoint>, IEnumerable<PgPoint>, IEnumerable, ISpanFormattable, IFormattable, IParsable<PgPath>
Constructors
Section titled “Constructors”PgPath(IEnumerable<PgPoint>, bool)
Section titled “PgPath(IEnumerable<PgPoint>, bool)”Copies the supplied points and records whether the last point connects back to the first.
public PgPath(IEnumerable<PgPoint> points, bool isClosed = false)Parameters:
points — IEnumerable<PgPoint>
The ordered vertices.
isClosed — bool
Whether the path is closed.
Properties
Section titled “Properties”Gets the number of vertices.
public int Count { get; }Value: int
IsClosed
Section titled “IsClosed”Gets whether the path is closed.
public bool IsClosed { get; }Value: bool
this[int]
Section titled “this[int]”Gets a vertex by its zero-based index.
public PgPoint this[int index] { get; }Parameters:
index — int
The vertex index.
Value: PgPoint
The point.
Points
Section titled “Points”Gets the vertices without exposing mutable storage.
public ReadOnlySpan<PgPoint> Points { get; }Value: ReadOnlySpan<PgPoint>
Methods
Section titled “Methods”GetEnumerator()
Section titled “GetEnumerator()”Enumerates vertices in order.
public IEnumerator<PgPoint> GetEnumerator()Returns: IEnumerator<PgPoint>
The vertex enumerator.
Parse(string)
Section titled “Parse(string)”Parses a path using PostgreSQL on the active backend.
public static PgPath Parse(string text)Parameters:
text — string
The path text.
Returns: PgPath
The owned path.
ToString()
Section titled “ToString()”Formats vertices with the path’s opening and closing delimiters without backend access.
public override string ToString()Returns: string
The path text.
ToString(string?, IFormatProvider?)
Section titled “ToString(string?, IFormatProvider?)”Formats the value as PostgreSQL’s canonical text, the same text as ToString().
public string ToString(string? format, IFormatProvider? formatProvider)Parameters:
format — string
Null or empty; PostgreSQL text has one canonical form.
formatProvider — IFormatProvider
Ignored: the text does not depend on culture.
Returns: string
The canonical text.
Exceptions:
- FormatException: A format is specified.
TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)
Section titled “TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)”Copies the value’s canonical PostgreSQL text into a span, as interpolated strings and other span-based formatters request it.
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)Parameters:
destination — Span<char>
The span that receives the text.
charsWritten — int
The number of characters written.
format — ReadOnlySpan<char>
Empty; PostgreSQL text has one canonical form.
provider — IFormatProvider
Ignored: the text does not depend on culture.
Returns: bool
Whether the text fit in the destination.
Exceptions:
- FormatException: A format is specified.
TryParse(string?, out PgPath?)
Section titled “TryParse(string?, out PgPath?)”Tries PostgreSQL parsing without swallowing backend-access or operational errors.
public static bool TryParse(string? text, out PgPath? value)Parameters:
text — string
The path text.
value — PgPath
The result, or null.
Returns: bool
Whether parsing succeeded.
Invalid input leaves no error pending: PostgreSQL 16 and later report it as a soft input error, and earlier majors roll back an internal subtransaction. Before PostgreSQL 16, transaction callbacks and parallel operations forbid that rollback; native errors there remain pending and throw PgException.
WithClosed(bool)
Section titled “WithClosed(bool)”Copies this path with a new open/closed flag.
public PgPath WithClosed(bool isClosed)Parameters:
isClosed — bool
The new flag.
Returns: PgPath
The independent path.