Пример #1
0
        private void setComment(IniFileElement el, string comment)
        {
            int num = parent.elements.IndexOf(el);

            if (IniFileSettings.CommentChars.Length == 0)
            {
                throw new NotSupportedException("Comments are currently disabled. Setup ConfigFileSettings.CommentChars property to enable them.");
            }
            if (num > 0 && parent.elements[num - 1] is IniFileCommentary)
            {
                IniFileCommentary iniFileCommentary = (IniFileCommentary)parent.elements[num - 1];
                if (comment == "")
                {
                    parent.elements.Remove(iniFileCommentary);
                    return;
                }
                iniFileCommentary.Comment     = comment;
                iniFileCommentary.Intendation = el.Intendation;
            }
            else if (comment != "")
            {
                IniFileCommentary iniFileCommentary = IniFileCommentary.FromComment(comment);
                iniFileCommentary.Intendation = el.Intendation;
                parent.elements.Insert(num, iniFileCommentary);
            }
        }