Ejemplo n.º 1
0
 // Used by Setting and Section in ToString().
 internal static string ConvertToString(Comment comment)
 {
     return comment.ToString();
 }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
 // Used by Setting and Section in ToString().
 internal static string ConvertToString(Comment comment)
 {
     return(comment.ToString());
 }