public void CreateSection(string Name) { clsSection newItem = new clsSection { Name = Name }; this.Sections.Add(newItem); }
public clsResult ReadFile(StreamReader File) { clsResult result2 = new clsResult("Reading INI"); int num3 = 0; int num2 = -1; string str = null; this.RootSection = new clsSection(); while (true) { str = File.ReadLine(); if (str == null) { this.Sections.RemoveBuffer(); if (num3 > 0) { result2.WarningAdd("There were " + Conversions.ToString(num3) + " invalid lines that were ignored."); } return result2; } str = str.Trim(); int index = str.IndexOf('#'); if (index >= 0) { str = Strings.Left(str, index).Trim(); } if (str.Length < 2) { if (str.Length > 0) { num3++; } } else if (str[0] != '[') { if (num2 >= 0) { index = str.IndexOf('='); if (index >= 0) { this.Sections[num2].CreateProperty(str.Substring(0, index).ToLower().Trim(), str.Substring(index + 1, (str.Length - index) - 1).Trim()); } else { num3++; } } else { index = str.IndexOf('='); if (index >= 0) { this.RootSection.CreateProperty(str.Substring(0, index).ToLower().Trim(), str.Substring(index + 1, (str.Length - index) - 1).Trim()); } else { num3++; } } } else if (str[str.Length - 1] != ']') { num3++; } else { string name = str.Substring(1, str.Length - 2); int num4 = this.Sections.Count - 1; index = 0; while (index <= num4) { if (this.Sections[index].Name == name) { break; } index++; } num2 = index; if (num2 == this.Sections.Count) { this.CreateSection(name); } } } }