//Create a YAMJData object from the configuration private YAMJData GetConfiguration() { //Create a new data object var data = new YAMJData(); var reader = new XmlSerializer(typeof(YAMJData)); //Read the configuration try { using (FileStream input = File.OpenRead(Constants.ConfigurationFile)) { data = reader.Deserialize(input) as YAMJData; } } catch (Exception) { //The file is in valid or damaged, lets create one from scretch SetConfiguration(); } return data; }
//Ctor public YAMJMe() { //Initialize the configuration object to the values from the configuration file _config = GetConfiguration(); }