FdbPath
Namespace: FoundationDB.Client · struct
Implements: IReadOnlyList<FdbPathSegment>, IEnumerable<FdbPathSegment>, IEnumerable, IReadOnlyCollection<FdbPathSegment>, IEquatable<FdbPath>, IComparable<FdbPath>, ISpanFormattable, IFormattable, IJsonDeserializable<FdbPath>, IJsonSerializable, IJsonPackable
Represents a path in a Directory Layer
Properties
Count
int Count { get; }
Number of segments in the path
IsEmpty
bool IsEmpty { get; }
Test if this is the empty directory
The path ("/") is NOT considered empty!
IsRoot
bool IsRoot { get; }
Test if this is the root directory ("/")
The path is NOT considered to be the root!
Item
FdbPathSegment Item { get; }
FdbPathSegment Item { get; }
FdbPath Item { get; }
FdbPath Item { get; }
FdbPath Item { get; }
FdbPath Item { get; }
FdbPath Item { get; }
LayerId
string LayerId { get; }
Returns the LayerId of the last segment of this path
Be convention, the LayerId of the path is the empty string, and the LayerId of the path is "partition"
Combine("Foo", "Bar", "Baz").Name => "Baz"
Name
string Name { get; }
Return the name of the last segment of this path
The name of the or paths is, by convention, the empty string.
Combine("Foo", "Bar", "Baz").Name => "Baz"
Methods
Absolute
static FdbPath Absolute(string segment)
Returns a relative path composed of a single segment
static FdbPath Absolute(FdbPathSegment segment)
Returns a relative path composed of a single segment
static FdbPath Absolute(params string[] segments)
Returns a relative path composed of the specified segments
static FdbPath Absolute(params FdbPathSegment[] segments)
Returns a relative path composed of the specified segments
static FdbPath Absolute(ReadOnlySpan<FdbPathSegment> segments)
Returns a relative path composed of the specified segments
static FdbPath Absolute(ReadOnlyMemory<FdbPathSegment> segments)
Returns a relative path composed of the specified segments
static FdbPath Absolute(IEnumerable<FdbPathSegment> segments)
Returns a relative path composed of the specified segments
Add
FdbPath Add(string name)
Appends a new segment to the current path
name— Name of the segment
This segment will not have any LayerId defined.
FdbPath Add(FdbPathSegment segment)
Appends a new segment to the current path
FdbPath Add(ReadOnlySpan<FdbPathSegment> segments)
Adds new segments to the current path
FdbPath Add(params FdbPathSegment[] segments)
Adds new segments to the current path
FdbPath Add(IEnumerable<FdbPathSegment> segments)
Adds new segments to the current path
FdbPath Add(FdbPath path)
Adds a path to the current path
FdbPath Add(string name, string layerId)
Appends a new segment to the current path
name— Name of the segmentlayerId— LayerId of the segment
AsAbsolute
FdbPath AsAbsolute()
Returns the equivalent absolute path, using the same path segments.
Returns: The absolute version of this path
This is the equivalent of adding this path to the path
"Foo/Bar".AsAbsolute() == "/Foo/Bar"; "/Foo/Bar".AsAbsolute() == "/Foo/Bar"
AsRelative
FdbPath AsRelative()
Returns the equivalent relative path, using the same path segments.
Returns: The relative version of this path
"/Foo/Bar".AsRelative() == "Foo/Bar"; "Foo/Bar".AsRelative() == "Foo/Bar"
Combine
static FdbPath Combine(FdbPath path, FdbPathSegment segment)
Adds a segment to a parent path
path— Parent pathsegment— Encoded path segment, composed of just a name ("Foo"), with an optional LayerId ("Foo[SomeLayer]")
static FdbPath Combine(FdbPath path, params FdbPathSegment[] segments)
Adds one or more segments to a parent path
static FdbPath Combine(FdbPath path, ReadOnlySpan<FdbPathSegment> segments)
Adds one or more segments to a parent path
static FdbPath Combine(FdbPath path, FdbPathSegment segment1, FdbPathSegment segment2)
Adds a pair of segments to a root path
CompareTo
int CompareTo(FdbPath other)
Encode
static string Encode(FdbPath path, bool namesOnly = false)
Encode a path into a string representation
path— Path to encodenamesOnly— Iftrue, omit the LayerIds in the resulting string.
Returns: String representation of the path (with or without the LayerId)
If is , the result will not round-trip into the original path (LayerIds will be lost).
EndsWith
bool EndsWith(FdbPath suffix)
Tests if the current path is the same or a parent of another path
This differs from in that a path always ends with itself
Equals
bool Equals(object obj)
bool Equals(FdbPath other)
GetEnumerator
IEnumerator<FdbPathSegment> GetEnumerator()
GetHashCode
int GetHashCode()
GetParent
FdbPath GetParent()
Returns the parent path of the current path
"/Foo/Bar/Baz".GetParent() => "/Foo/Bar"
GetRelativePath
FdbPath GetRelativePath(FdbPath parent)
Returns the relative part of this path inside its parent
parent— Parent of this path
Returns: Returns the relative portion of the current path under its parent. It this path is equal to parent, returns Empty.
"/Foo/Bar/Baz".GetRelativePath("/Foo") => "Bar/Baz"
IsChildOf
bool IsChildOf(FdbPath prefix)
Tests if the current path is a child of another path
This differs from in that a path is not a child of itself
IsParentOf
bool IsParentOf(FdbPath suffix)
Tests if the current path is a parent of another path
This differs from in that a path is not a parent of itself
Parse
static FdbPath Parse(string path)
Parses a string representing a path into the corresponding FdbPath instance.
path— Path (either absolute or relative).
Returns: Corresponding path.
This method can take the out of and return the original path.
static FdbPath Parse(ReadOnlySpan<char> path)
Parses a string representing a path into the corresponding FdbPath instance.
path— Path (either absolute or relative).
Returns: Corresponding path.
This method can take the out of and return the original path.
Relative
static FdbPath Relative(string segment)
Returns a relative path composed of a single segment
segment— Encoded path segment, composed of just a name ("Foo"), with an optional LayerId ("Foo[SomeLayer]")
static FdbPath Relative(FdbPathSegment segment)
Returns a relative path composed of a single segment
static FdbPath Relative(params string[] segments)
Returns a relative path composed of the specified segments
segments— Array of encoded path segments, composed of just a name ("Foo"), with an optional LayerId ("Foo[SomeLayer]")
static FdbPath Relative(params FdbPathSegment[] segments)
Returns a relative path composed of the specified segments
static FdbPath Relative(ReadOnlySpan<FdbPathSegment> segments)
Returns a relative path composed of the specified segments
static FdbPath Relative(ReadOnlyMemory<FdbPathSegment> segments)
Returns a relative path composed of the specified segments
static FdbPath Relative(IEnumerable<FdbPathSegment> segments)
Returns a relative path composed of the specified segments
segments— Sequence of path segment, composed of just a name ("Foo"), with an optional LayerId ("Foo[SomeLayer]")
StartsWith
bool StartsWith(FdbPath prefix)
Tests if the current path is the same, or a child of another path
This differs from in that a path always starts with itself
Substring
FdbPath Substring(int offset)
Returns a suffix of the current path
offset— Number of segments to skip
FdbPath Substring(int offset, int count)
Returns a subsection of the current path
offset— Number of segments to skipcount— Number of segments to keep
ToString
string ToString()
Returns a serialized string that represents this path.
Returns: All the path segments joined with a '/'. If the path is absolute, starts with a leading '/'
Any string produced by this method can be passed back to to get back the original path.
string ToString(string format, IFormatProvider provider = null)
Returns a serialized string that represents this path.
format— Supported formats arenullor"D"to include layer ids, and"N"for names onlyprovider— The value is ignored
Returns: All the path segments joined with a '/'. If the path is absolute, starts with a leading '/'
Supported formats: FormatResultD``"/Tenants/ACME[partition]/Documents/Users"``N``"/Tenants/ACME/Documents/Users"
Any string produced by this method can be passed back to Parse to get back the original path.
TryFormat
bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = null, IFormatProvider provider = null)
TryGetParent
bool TryGetParent(out FdbPath parent)
Gets the parent path of the current path, if it is not empty.
parent— Receive the path of the parent, if there is one.
Returns: If true, parent contains the parent path. If false, the current path was Empty or the Root, and does not have a parent.
"/Foo/Bar/Baz".TryGetParent() => (true, "/Foo/Bar")
TryGetRelative
bool TryGetRelative(FdbPath parent, out FdbPath relative)
Returns the relative path that, if added to parent, would be equal to the current path.
parent— Parent path. Must be of the same type (absolute/relative) as the current path.relative— If the method returnstrue, receives the relative path fromparentto the current path.
Returns: Returns true if parent is an ancestor or equal to the current path; otherwise, returns false.
TryGetRelativePath
bool TryGetRelativePath(FdbPath parent, out FdbPath relativePath)
Returns the relative part of this path inside its parent
parent— Parent of this pathrelativePath— If this path is equal to, or a child orparent, receives the relative path; otherwise, Empty.
Returns: Returns true if path is equal to, or a child of parent; otherwise, false.
If this path is equal to , still returns true but will be empty.
"/Foo/Bar/Baz".TryGetRelativePath("/Foo") => (true, "Bar/Baz")
TryParse
static bool TryParse(ReadOnlySpan<char> path, out FdbPath result)
Parses a string representing a path into the corresponding FdbPath instance, if it is valid.
WithLayer
FdbPath WithLayer(string layerId)
Returns the same path, but with the specified LayerId
layerId— LayerId value for this path
Returns: New path that points to the same location, but with the attached LayerId metadata
Fields
Empty
static readonly FdbPath Empty
The "empty" path
This path is relative
IsAbsolute
readonly bool IsAbsolute
If true, this is an absolute path (ex: "/Foo/Bar"); otherwise, this a relative path ("Foo/Bar")
Root
static readonly FdbPath Root
The "root" path ("/").
This path is absolute
Segments
readonly ReadOnlyMemory<FdbPathSegment> Segments
Segments of this path