// Used by Setting and Section in ToString(). internal static string ConvertToString(Comment comment) { return comment.ToString(); }
private static Comment? ParseComment(string line, out int commentIndex) { Comment? comment = null; commentIndex = -1; do { commentIndex = line.IndexOfAny(ValidCommentChars, commentIndex + 1); if (commentIndex < 0) break; // Tip from MarkAJones: // Database connection strings can contain semicolons, which should not be // treated as comments, but rather separators. // To avoid this, we have to check for two things: // 1. Is the comment inside a string? If so, ignore. // 2. Is the comment symbol backslashed (an escaping value)? If so, ignore also. // If the char before the comment is a backslash, it's not a comment. if (commentIndex >= 1 && line[commentIndex - 1] == '\\') return null; if (IsInQuoteMarks(line, commentIndex)) continue; comment = new Comment( value: line.Substring(commentIndex + 1).Trim(), symbol: line[commentIndex]); break; } while (commentIndex >= 0); return comment; }
// Used by Setting and Section in ToString(). internal static string ConvertToString(Comment comment) { return(comment.ToString()); }