private T LoadConfigFile <T>(string fileName, T instance) { String filePath = (BTConfigHolder.basePath + fileName).Replace('/', Path.DirectorySeparatorChar); if (!File.Exists(filePath)) { return(default(T)); } try { using (StreamReader reader = File.OpenText(filePath)){ if (instance == null) { return(BTConfigUtils.LoadConfig <T>(reader)); } else { BTConfigUtils.LoadConfig <T>(reader, instance); return(instance); } } }catch (Exception e) { this.LogMessage(LogType.Error, "Encountered an exception during parsing of the file `" + fileName + "`!\nException: " + e.ToString()); return(default(T)); } }
private void LoadHackConfig() { if (!AreHacksEnabled()) { hackConfig = null; return; } try{ using (StreamReader reader = File.OpenText((basePath + hackConfigFileName).Replace('/', Path.DirectorySeparatorChar))){ hackConfig = BTConfigUtils.LoadConfig <BTHackConfig>(reader); } }catch (Exception e) { LogMessage(LogType.Error, "Encountered an exception during parsing of the hackConfig!\nException: " + e.ToString()); hackConfig = null; } }