/// <summary> /// Gets a string that represents the setting. /// </summary> /// /// <param name="includeComment">Specify true to include the comments in the string; false otherwise.</param> public string ToString(bool includeComment) { if (includeComment) { bool hasPreComments = mPreComments != null && mPreComments.Count > 0; string[] preCommentStrings = hasPreComments ? mPreComments.ConvertAll(c => c.ToString()).ToArray() : null; if (Comment != null && hasPreComments) { // Include inline comment and pre-comments. return(string.Format("{0}\n{1}={2} {3}", string.Join(Environment.NewLine, preCommentStrings), Name, mRawValue, Comment.ToString())); } else if (Comment != null) { // Include only the inline comment. return(string.Format("{0}={1} {2}", Name, mRawValue, Comment.ToString())); } else if (hasPreComments) { // Include only the pre-comments. return(string.Format("{0}\n{1}={2}", string.Join(Environment.NewLine, preCommentStrings), Name, mRawValue)); } } // In every other case, include just the assignment in the string. return(string.Format("{0}={1}", Name, mRawValue)); }
/// <summary> /// Convert this object into a string representation. /// </summary> /// /// <param name="includeComment">True to include, false to exclude the comment.</param> /// /// <returns> /// A string that represents the current object. /// </returns> public string ToString(bool includeComment) { if (includeComment) { bool hasPreComments = mPreComments != null && mPreComments.Count > 0; string[] preCommentStrings = hasPreComments ? mPreComments.ConvertAll <string>(Comment.ConvertToString).ToArray() : null; if (Comment != null && hasPreComments) { // Include inline comment and pre-comments. return(string.Format("{0}\n[{1}] {2}", string.Join(Environment.NewLine, preCommentStrings), Name, Comment.ToString())); } else if (Comment != null) { // Include only the inline comment. return(string.Format("[{0}] {1}", Name, Comment.ToString())); } else if (hasPreComments) { // Include only the pre-comments. return(string.Format("{0}\n[{1}]", string.Join(Environment.NewLine, preCommentStrings), Name)); } } return(string.Format("[{0}]", Name)); }
/// <summary> /// Gets the string representation of the section. /// </summary> /// /// <param name="includeComment">True to include, false to exclude the comment.</param> public string ToString(bool includeComment) { if (includeComment) { bool hasPreComments = mPreComments != null && mPreComments.Count > 0; string[] preCommentStrings = hasPreComments ? mPreComments.Select(c => c.ToString()).ToArray() : null; if (Comment != null && hasPreComments) { // Include inline comment and pre-comments. return(string.Format("{0}{1}[{2}] {3}", string.Join(Environment.NewLine, preCommentStrings), // {0} Environment.NewLine, // {1} Name, // {2} Comment.ToString() // {3} )); } else if (Comment != null) { // Include only the inline comment. return(string.Format("[{0}] {1}", Name, Comment.ToString())); } else if (hasPreComments) { // Include only the pre-comments. return(string.Format("{0}{1}[{2}]", string.Join(Environment.NewLine, preCommentStrings), // {0} Environment.NewLine, // {1} Name // {2} )); } } return(string.Format("[{0}]", Name)); }
// Used by Setting and Section in ToString(). internal static string ConvertToString(Comment comment) { return comment.ToString(); }
// Used by Setting and Section in ToString(). internal static string ConvertToString(Comment comment) { return(comment.ToString()); }