Struct ShapeShiftPath
- Namespace
- ShapeShift
- Assembly
- ShapeShift.dll
Identifies the location of a value within a serialized document as a sequence of ShapeShiftPathElement steps, each of which is either a map property name or a vector index.
public readonly struct ShapeShiftPath : IEquatable<ShapeShiftPath>, IEnumerable<ShapeShiftPathElement>, IEnumerable
- Implements
- Inherited Members
Remarks
This type is format-neutral: the same path may be used to seek within a JSON document, a MessagePack document,
or any other ShapeShift-supported encoding, via the TrySeek decoder extension member declared in DecoderExtensions.
Construct a path with a collection expression or the constructor's params parameter,
taking advantage of the implicit conversions from string and int
to ShapeShiftPathElement, e.g. new ShapeShiftPath("items", 2, "name").
Constructors
ShapeShiftPath(params ReadOnlySpan<ShapeShiftPathElement>)
Initializes a new instance of the ShapeShiftPath struct.
public ShapeShiftPath(params ReadOnlySpan<ShapeShiftPathElement> elements)
Parameters
elementsReadOnlySpan<ShapeShiftPathElement>The ordered steps that locate a value, starting from the root of the document.
Properties
Count
Gets the number of elements (steps) in this path.
public int Count { get; }
Property Value
this[int]
Gets the element at the given 0-based index within this path.
public ShapeShiftPathElement this[int index] { get; }
Parameters
indexintThe 0-based index into the path.
Property Value
- ShapeShiftPathElement
The element at that position.
Root
Gets the path that identifies the root of the document (i.e. an empty sequence of elements).
public static ShapeShiftPath Root { get; }
Property Value
Methods
Equals(ShapeShiftPath)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(ShapeShiftPath other)
Parameters
otherShapeShiftPathAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetEnumerator()
Gets an enumerator over the elements in this path.
public ImmutableArray<ShapeShiftPathElement>.Enumerator GetEnumerator()
Returns
- ImmutableArray<ShapeShiftPathElement>.Enumerator
The enumerator.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
ToString()
Renders this path in a JSONPath-like notation (e.g. $.items[2].name) for diagnostic purposes.
public override string ToString()
Returns
- string
The rendered path.
Operators
operator ==(ShapeShiftPath, ShapeShiftPath)
Checks two paths for equality.
public static bool operator ==(ShapeShiftPath left, ShapeShiftPath right)
Parameters
leftShapeShiftPathThe first path.
rightShapeShiftPathThe second path.
Returns
operator !=(ShapeShiftPath, ShapeShiftPath)
Checks two paths for inequality.
public static bool operator !=(ShapeShiftPath left, ShapeShiftPath right)
Parameters
leftShapeShiftPathThe first path.
rightShapeShiftPathThe second path.