public INIReader(StreamReader streamReader)
{
if (streamReader != null)
{
Dictionary<string, string> currentSection = null;
string line;
while ((line = streamReader.ReadLine()) != null)
{
// Remove comments
int pos = line.IndexOf(';');
if (pos != -1)
{
if (pos == 0)
line = "";
else
line.Substring(0, pos);
}
// Get the section
pos = line.IndexOf('[');
if (pos != -1)
{
string section = line.Substring(pos + 1);
pos = section.IndexOf(']');
if (pos != -1)
section = section.Substring(0, pos);
if (!this.sections.ContainsKey(section))
currentSection = this.sections[section] = new Dictionary<string, string>();
continue;
}
// Get the entry
pos = line.IndexOf('=');
if (pos != -1 && currentSection != null)
{
string key = line.Substring(0, pos).Trim();
string value = line.Substring(pos + 1).Trim();
currentSection[key] = value;
continue;
}
}
}
}