private void SetComment(IniElement el, string comment) { var index = Parent.Elements.IndexOf(el); if (IniSettings.CommentChars.Length == 0) { throw new NotSupportedException("Comments are currently disabled. Setup ConfigFileSettings.CommentChars property to enable them."); } IniCommentary com; if (index > 0 && Parent.Elements[index - 1] is IniCommentary) { com = ((IniCommentary)Parent.Elements[index - 1]); if (comment == "") { Parent.Elements.Remove(com); } else { com.Comment = comment; com.Indentation = el.Indentation; } } else if (comment != "") { com = IniCommentary.FromComment(comment); com.Indentation = el.Indentation; Parent.Elements.Insert(index, com); } }
public void InsertComment(string comment) { var com = IniCommentary.FromComment(comment); Parent.Elements.Add(com); }