public void LoadConfiguration() { TextReader reader = null; try { configuration = new DemoCritterBrain1Configuration(); reader = new StreamReader(ConfigurationFileName); string line; while ((line = reader.ReadLine()) != null) { string[] components = line.Split('='); if (components.Length != 2) { continue; } string key = components[0]; string value = components[1]; if (key == "nominalSpeed") { int nominalSpeed; if (int.TryParse(value, out nominalSpeed)) { configuration.NominalSpeed = nominalSpeed; } } } } catch (FileNotFoundException) { Console.WriteLine(ConfigurationFileName + " does not exist. Using defaults."); } catch (Exception e) { Console.WriteLine("LoadConfiguration error: " + e.Message); } finally { if (reader != null) { reader.Close(); } } }
public void ObtainDefaultConfiguration() { configuration = new DemoCritterBrain1Configuration(); }