/// <summary> /// Creates a structurally equivalent ancestor path segment from a given segment. /// </summary> /// <param name="segment">The segment to copy the structure from.</param> /// <returns>A structurally equivalent copy of the given segment.</returns> public static IStonAncestorPathSegment Copy(IStonAncestorPathSegment segment) { if (segment == null) { throw new ArgumentNullException("segment"); } return(new StonAncestorPathSegment(segment)); }
/// <summary> /// Checks the validity of a given STON ancestor path segment. /// </summary> /// <param name="segment">The path segment to check the validity of.</param> public static void ValidatePathSegment(IStonAncestorPathSegment segment) { if (segment == null) { throw new ArgumentNullException("segment"); } if (segment.AncestorOrder <= 0) { throw new StonException("An ancestor path segment must have a positive ancestor order."); } }
// writes an ancestor access path segment private void WritePathSegment(StonTokenWriter writer, IStonAncestorPathSegment segment) { writer.Write('.'); writer.Write(new string('^', segment.AncestorOrder)); }
/// <summary> /// Creates a structurally equivalent ancestor path segment from a given segment. /// </summary> /// <param name="segment">The segment to copy the structure from.</param> public StonAncestorPathSegment(IStonAncestorPathSegment segment) : this(segment.AncestorOrder) { }