Пример #1
0
        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());
        }
Пример #2
0
        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);
        }
Пример #3
0
        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;
        }
Пример #4
0
	   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();
	   }