public static IniElement 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."); } var trim = line.Trim(); IniElement elem = null; if (IniBlankLine.IsLineValid(trim)) { elem = new IniBlankLine(1); } else if (IniCommentary.IsLineValid(line)) { elem = new IniCommentary(line); } else if (IniSectionStart.IsLineValid(trim)) { elem = new IniSectionStart(line); } else if (IniValue.IsLineValid(trim)) { elem = new IniValue(line); } return(elem ?? new IniElement(line)); }
public IniValue GotoValue(string key, bool searchWholeFile) { while (true) { var str = ReadLine(); if (str == null) { return(null); } if (IniValue.IsLineValid(str.Trim())) { var val = ParseLine(str) as IniValue; if (val != null && (val.Key == key || (!IniSettings.CaseSensitive && val.Key.ToLowerInvariant() == key.ToLowerInvariant()))) { return(val); } } if (!searchWholeFile && IniSectionStart.IsLineValid(str.Trim())) { return(null); } } }