internal static IniTree BuildIniTree(string iniPath) { using (StreamReader sr = new StreamReader(iniPath)) { IniTree iniTree = new IniTree(); string line; while ((line = sr.ReadLine()) != null) { if (line.StartsWith(";",StringComparison.Ordinal) == true) { IniComment iniComment = new IniComment() { Text = line }; IniSection lastSection = (IniSection)iniTree.Nodes.Where(temp => temp is IniSection).LastOrDefault(); if (lastSection == null) { iniTree.Nodes.Add(iniComment); } else { lastSection.Nodes.Add(iniComment); } } else if (line.StartsWith("[", StringComparison.Ordinal) == true && line.EndsWith("]", StringComparison.Ordinal) == true) { IniSection iniSection = new IniSection() { Text = line }; iniTree.Nodes.Add(iniSection); } else if (line.Contains('=') == true && iniTree.Nodes.Count(temp => temp is IniSection) > 0) { IniKey iniKey = new IniKey() { Text = line }; IniSection lastSection = (IniSection)iniTree.Nodes.Where(temp => temp is IniSection).Last(); lastSection.Nodes.Add(iniKey); } else { IniUnknownLine iniUnknownLine = new IniUnknownLine() { Text = line }; IniSection lastSection = (IniSection)iniTree.Nodes.Where(temp => temp is IniSection).LastOrDefault(); if (lastSection == null) { iniTree.Nodes.Add(iniUnknownLine); } else { lastSection.Nodes.Add(iniUnknownLine); } } } return iniTree; } }
internal static IniTree BuildIniTree(string iniPath) { using (StreamReader sr = new StreamReader(iniPath)) { IniTree iniTree = new IniTree(); string line; while ((line = sr.ReadLine()) != null) { if (line.StartsWith(";", StringComparison.Ordinal) == true) { IniComment iniComment = new IniComment() { Text = line }; IniSection lastSection = (IniSection)iniTree.Nodes.Where(temp => temp is IniSection).LastOrDefault(); if (lastSection == null) { iniTree.Nodes.Add(iniComment); } else { lastSection.Nodes.Add(iniComment); } } else if (line.StartsWith("[", StringComparison.Ordinal) == true && line.EndsWith("]", StringComparison.Ordinal) == true) { IniSection iniSection = new IniSection() { Text = line }; iniTree.Nodes.Add(iniSection); } else if (line.Contains('=') == true && iniTree.Nodes.Count(temp => temp is IniSection) > 0) { IniKey iniKey = new IniKey() { Text = line }; IniSection lastSection = (IniSection)iniTree.Nodes.Where(temp => temp is IniSection).Last(); lastSection.Nodes.Add(iniKey); } else { IniUnknownLine iniUnknownLine = new IniUnknownLine() { Text = line }; IniSection lastSection = (IniSection)iniTree.Nodes.Where(temp => temp is IniSection).LastOrDefault(); if (lastSection == null) { iniTree.Nodes.Add(iniUnknownLine); } else { lastSection.Nodes.Add(iniUnknownLine); } } } return(iniTree); } }