Esempio n. 1
0
 private static void AugmentCmdrInfo(Commander cmdr)
 {
     if (cmdr != null)
     {
         CommanderConfiguration cmdrConfiguration = CommanderConfiguration.FromFile();
         if (cmdrConfiguration.PhoneticName == null || cmdrConfiguration.PhoneticName.Trim().Length == 0)
         {
             cmdr.PhoneticName = null;
         }
         else
         {
             cmdr.PhoneticName = cmdrConfiguration.PhoneticName;
         }
     }
 }
        /// <summary>
        /// Obtain commander config from a file. If  If the file name is not supplied the the default
        /// path of %APPDATA%\EDDI\commander.json is used
        /// </summary>
        /// <param name="filename"></param>
        public static CommanderConfiguration FromFile(string filename = null)
        {
            if (filename == null)
            {
                String dataDir = Environment.GetEnvironmentVariable("AppData") + "\\EDDI";
                Directory.CreateDirectory(dataDir);
                filename = dataDir + "\\commander.json";
            }

            CommanderConfiguration speech;
            try
            {
                String configData = File.ReadAllText(filename);
                speech = JsonConvert.DeserializeObject<CommanderConfiguration>(configData);
            }
            catch
            {
                speech = new CommanderConfiguration();
            }

            speech.dataPath = filename;
            return speech;
        }
Esempio n. 3
0
        /// <summary>
        /// Obtain commander config from a file. If  If the file name is not supplied the the default
        /// path of %APPDATA%\EDDI\commander.json is used
        /// </summary>
        /// <param name="filename"></param>
        public static CommanderConfiguration FromFile(string filename = null)
        {
            if (filename == null)
            {
                String dataDir = Environment.GetEnvironmentVariable("AppData") + "\\EDDI";
                Directory.CreateDirectory(dataDir);
                filename = dataDir + "\\commander.json";
            }

            CommanderConfiguration speech;

            try
            {
                String configData = File.ReadAllText(filename);
                speech = JsonConvert.DeserializeObject <CommanderConfiguration>(configData);
            }
            catch
            {
                speech = new CommanderConfiguration();
            }

            speech.dataPath = filename;
            return(speech);
        }