StringDictionary GetProperties4 (string item)
{
string file = StatisticsFile;
string head = item + ": ";
using (StreamReader sr = new StreamReader (file, Encoding.ASCII)) {
string [] keys = null;
string [] values = null;
string s = String.Empty;
do {
s = sr.ReadLine ();
if (String.IsNullOrEmpty (s))
continue;
if (s.Length <= head.Length || String.CompareOrdinal (s, 0, head, 0, head.Length) != 0)
continue;
if (keys == null)
keys = s.Substring (head.Length).Split (' ');
else if (values != null)
// hmm, there may be better error type...
throw CreateException (file, String.Format ("Found duplicate line for values for the same item '{0}'", item));
else {
values = s.Substring (head.Length).Split (' ');
break;
}
} while (!sr.EndOfStream);
if (values == null)
throw CreateException (file, String.Format ("No corresponding line was not found for '{0}'", item));
if (keys.Length != values.Length)
throw CreateException (file, String.Format ("The counts in the header line and the value line do not match for '{0}'", item));
StringDictionary dic = new StringDictionary ();
for (int i = 0; i < keys.Length; i++)
dic [keys [i]] = values [i];
return dic;
}
}