Esempio n. 1
0
        /// <summary>Gets an IniFileCommentary object from commentary text.</summary>
        /// <param name="comment">Commentary text.</param>
        public static IniFileCommentary FromComment(string comment)
        {
            if (IniFileSettings.CommentChars.Length == 0)
            {
                throw new NotSupportedException("Comments are disabled. Set the IniFileSettings.CommentChars property to turn them on.");
            }
            IniFileCommentary ret = new IniFileCommentary();

            ret.comment     = comment;
            ret.CommentChar = IniFileSettings.CommentChars[0];
            return(ret);
        }
Esempio n. 2
0
 /// <summary>Parses a single line.</summary>
 /// <param name="line">Text to parse.</param>
 public static IniFileElement ParseLine(string line)
 {
     if (line == null)
         return null;
     if (line.Contains("\n"))
         throw new ArgumentException("String passed to the ParseLine method cannot contain more than one line.");
     string trim = line.Trim();
     IniFileElement elem = null;
     if (IniFileBlankLine.IsLineValid(trim))
         elem = new IniFileBlankLine(1);
     else if (IniFileCommentary.IsLineValid(line))
         elem = new IniFileCommentary(line);
     else if (IniFileSectionStart.IsLineValid(trim))
         elem = new IniFileSectionStart(line);
     else if (IniFileValue.IsLineValid(trim))
         elem = new IniFileValue(line);
     return elem ?? new IniFileElement(line);
 }
 /// <summary>Gets an IniFileCommentary object from commentary text.</summary>
 /// <param name="comment">Commentary text.</param>
 public static IniFileCommentary FromComment(string comment)
 {
     if (IniFileSettings.CommentChars.Length == 0)
         throw new NotSupportedException("Comments are disabled. Set the IniFileSettings.CommentChars property to turn them on.");
     IniFileCommentary ret = new IniFileCommentary();
     ret.comment = comment;
     ret.CommentChar = IniFileSettings.CommentChars[0];
     return ret;
 }