public static IniSection[] Parse(string[] lines) { SectionBuilder builder = new SectionBuilder(); for (int i = 0; i < lines.Length; i++) { if (string.IsNullOrEmpty(lines[i])) { continue; } // ignore empty lines string currentLine = lines[i].Trim(); if (currentLine.StartsWith("#")) { continue; // ignore comments } else if (currentLine.StartsWith("[") && currentLine.EndsWith("]")) { builder.AddSection(currentLine.Substring(1, currentLine.Length - 2)); } else { builder.Add(lines[i]); } } builder.Pop(); builder.sections.Sort(); return(builder.sections.ToArray()); }
public static Dictionary <string, HashSet <string> > Parse(IEnumerable <string> lines) { SectionBuilder builder = new SectionBuilder(); int lineNumber = 0; foreach (string t in lines) { lineNumber++; string currentLine = t.Trim(); if (string.IsNullOrEmpty(currentLine)) { continue; // ignore empty lines } if (currentLine.StartsWith("#")) { continue; // ignore comments } if (currentLine.StartsWith("[") && currentLine.EndsWith("]")) { string sectionName = currentLine.Substring(1, currentLine.Length - 2); ThrowIfContainsInvalidCharacters(sectionName, lineNumber); builder.BeginSection(sectionName); } else { builder.Add(currentLine, lineNumber); } } return(builder.Sections); }
public static Dictionary<string, HashSet<string>> Parse(IEnumerable<string> lines) { SectionBuilder builder = new SectionBuilder(); int lineNumber = 0; foreach (string t in lines) { lineNumber++; string currentLine = t.Trim(); if (string.IsNullOrEmpty(currentLine)) continue; // ignore empty lines if (currentLine.StartsWith("#")) continue; // ignore comments if (currentLine.StartsWith("[") && currentLine.EndsWith("]")) { string sectionName = currentLine.Substring(1, currentLine.Length - 2); ThrowIfContainsInvalidCharacters(sectionName, lineNumber); builder.BeginSection(sectionName); } else { builder.Add(currentLine, lineNumber); } } return builder.Sections; }
public static IniSection[] Parse(string[] lines) { SectionBuilder builder = new SectionBuilder(); for (int i = 0; i < lines.Length; i++) { if(string.IsNullOrEmpty(lines[i])){ continue; } // ignore empty lines string currentLine = lines[i].Trim(); if (currentLine.StartsWith("#")) { continue; // ignore comments }else if (currentLine.StartsWith("[") && currentLine.EndsWith("]")) { builder.AddSection(currentLine.Substring(1, currentLine.Length - 2)); } else { builder.Add(lines[i]); } } builder.Pop(); builder.sections.Sort(); return builder.sections.ToArray(); }