using System.Diagnostics; namespace MadMilkman.Ini { /// /// Represents a comment object used by objects, and . /// [DebuggerDisplay("Text = {Text}")] public sealed class IniComment { [DebuggerBrowsable(DebuggerBrowsableState.Never)] private string text; [DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly IniCommentType type; /// /// Gets or sets the amount of empty lines before this comment's text. /// public int EmptyLinesBefore { get; set; } /// /// Gets or sets the amount of whitespace characters before this comment's text. /// public int LeftIndentation { get; set; } /// /// Gets or sets a text of this instance. /// /// /// For LeadingComment text should not contain new line characters. /// If it does, they will be replaced with a space characters. /// public string Text { get { return this.text; } set { if (value != null && this.type == IniCommentType.Leading) this.text = value.Replace("\r\n", " ") .Replace("\n", " ") .Replace("\r", " "); else this.text = value; } } internal IniComment(IniCommentType type) { this.type = type; } // Deep copy constructor. internal IniComment(IniComment source) { this.text = source.text; this.type = source.type; this.EmptyLinesBefore = source.EmptyLinesBefore; this.LeftIndentation = source.LeftIndentation; } } }