예제 #1
0
        private void PopulateRaces()
        {
            try
            {
                Races = Newtonsoft.Json.JsonConvert.DeserializeObject <List <DefaultRace> >(FileReader.ReadFile(FileHandlersCfg.FilePathRacesFile));
            }
            catch (Exception e)
            {
                JLogger.LogError(e);
                JLogger.LogDebug("Races could not be found. Creating new default Races file.");
            }

            if (Races != null)
            {
                if (Races.Any())
                {
                    return;
                }
            }

            Races = new ListOfDefaultRaces();

            string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(Races);

            FileWriter.WriteFile(FileHandlersCfg.FilePathRacesFile, jsonString);
        }