using System; namespace lliurex { namespace controlcenter { /** * Reads text conf files using "var = value" pattern. * * **/ public class PropertyReader { public System.Collections.Generic.Dictionary values; public PropertyReader(String filename) { System.IO.StreamReader reader = new System.IO.StreamReader(filename); values = new System.Collections.Generic.Dictionary(); System.Text.RegularExpressions.Regex assignation = new System.Text.RegularExpressions.Regex("(?.*)=(?.*)"); while(!reader.EndOfStream) { String tmp = reader.ReadLine(); System.Text.RegularExpressions.Match m = assignation.Match(tmp); if (m.Success) { string var = m.Groups["var"].Value.Trim(); string val = m.Groups["value"].Value.Trim(); //System.Console.WriteLine("Match: " + var); //System.Console.WriteLine("Value: " + val); if(!values.ContainsKey(var)) { values.Add(var,val); } } } reader.Close(); } }//class } }