Exemple #1
0
        private void setComment(IniFileElement el, string comment)
        {
            int index = parent.elements.IndexOf(el);

            if (IniFileEx.CommentChars.Length == 0)
            {
                throw new NotSupportedException("Comments are currently disabled. Setup ConfigFileSettings.CommentChars property to enable them.");
            }
            IniFileCommentary com;

            if (index > 0 && parent.elements[index - 1] is IniFileCommentary)
            {
                com = ((IniFileCommentary)parent.elements[index - 1]);
                if (comment == "")
                {
                    parent.elements.Remove(com);
                }
                else
                {
                    com.Comment     = comment;
                    com.Intendation = el.Intendation;
                }
            }
            else if (comment != "")
            {
                com             = IniFileCommentary.FromComment(comment);
                com.Intendation = el.Intendation;
                parent.elements.Insert(index, com);
            }
        }