/// <summary> /// Parse comment from <paramref name="startPosition"/> position in <paramref name="text"/> /// string and return position to next character after element. /// </summary> /// <param name="text">String that will be parsed</param> /// <param name="startPosition">Position from which parsing will start</param> /// <param name="comment">Result of parsing</param> /// <returns>Position to next character after element</returns> private int ParseComment(string text, int startPosition, out SchemaComment comment) { comment = null; var nextPosition = NextElementStartPosition(text, startPosition); if (IsEOF(text, nextPosition)) // no one comment left { return(startPosition); } var commentMatch = _commentRx.Match(text, nextPosition); if (!commentMatch.Success) { return(startPosition); } if (commentMatch.Index != nextPosition) // means that next item is not a comment { return(startPosition); } var builder = BuilderFactory.Create(); builder.SetValue(commentMatch.Value); comment = builder.BuildComment(); return(PositionAfterElement(commentMatch)); }
private string StringifyComment(SchemaComment comment, int depth) { var tabs = new string('\t', depth); return($"{tabs}{comment.Value}{Environment.NewLine}"); }