/// <summary> /// Obtain commander config from a file. If If the file name is not supplied the the default /// path of Constants.Data_DIR\commander.json is used /// </summary> /// <param name="filename"></param> public static CommanderConfiguration FromFile(string filename = null) { if (filename == null) { filename = Constants.DATA_DIR + @"\commander.json"; } CommanderConfiguration configuration = new CommanderConfiguration(); try { string configData = File.ReadAllText(filename); configuration = JsonConvert.DeserializeObject <CommanderConfiguration>(configData); } catch (Exception ex) { Logging.Debug("Failed to read commander configuration", ex); } if (configuration == null) { configuration = new CommanderConfiguration(); } configuration.dataPath = filename; return(configuration); }
private static void AugmentCmdrInfo(Commander cmdr) { Logging.Debug("Entered"); if (cmdr != null) { CommanderConfiguration cmdrConfiguration = CommanderConfiguration.FromFile(); if (cmdrConfiguration.PhoneticName == null || cmdrConfiguration.PhoneticName.Trim().Length == 0) { cmdr.phoneticname = null; } else { cmdr.phoneticname = cmdrConfiguration.PhoneticName; } } Logging.Debug("Leaving"); }
/// <summary> /// Obtain commander config from a file. If If the file name is not supplied the the default /// path of Constants.Data_DIR\commander.json is used /// </summary> /// <param name="filename"></param> public static CommanderConfiguration FromFile(string filename = null) { if (filename == null) { filename = Constants.DATA_DIR + @"\commander.json"; } CommanderConfiguration speech = new CommanderConfiguration(); try { string configData = File.ReadAllText(filename); speech = JsonConvert.DeserializeObject<CommanderConfiguration>(configData); } catch {} speech.dataPath = filename; return speech; }
/// <summary> /// Obtain commander config from a file. If If the file name is not supplied the the default /// path of Constants.Data_DIR\commander.json is used /// </summary> /// <param name="filename"></param> public static CommanderConfiguration FromFile(string filename = null) { if (filename == null) { filename = Constants.DATA_DIR + @"\commander.json"; } CommanderConfiguration speech = new CommanderConfiguration(); try { string configData = File.ReadAllText(filename); speech = JsonConvert.DeserializeObject <CommanderConfiguration>(configData); } catch {} speech.dataPath = filename; return(speech); }