public static void LoadSolarSystems() { var assembly = Assembly.GetExecutingAssembly(); string resourceName = assembly.GetManifestResourceNames() .Single(str => str.EndsWith("mapSolarSystems.csv")); var stream = assembly.GetManifestResourceStream(resourceName); StreamReader reader = new StreamReader(stream); reader.ReadLine(); while (!reader.EndOfStream) { var currentLine = reader.ReadLine(); var lineValues = currentLine.Split(','); try { var systemName = lineValues[3]; int systemId; Int32.TryParse(lineValues[2].ToString(), out systemId); SystemIdToNameDictionary.Add(systemId, systemName); NameToSystemIdDictionary.Add(systemName, systemId); } catch (Exception e) { Console.WriteLine(e); throw; } } }
public static void LoadSolarSystems() { var assembly = Assembly.GetExecutingAssembly(); var map = new List <EveSystem>(); string mapResourceName = assembly.GetManifestResourceNames() .Single(str => str.EndsWith("EveMap.json")); var mapStream = assembly.GetManifestResourceStream(mapResourceName); var serializer = new JsonSerializer(); using (var sr = new StreamReader(mapStream)) using (var jsonTextReader = new JsonTextReader(sr)) { map = serializer.Deserialize <List <EveSystem> >(jsonTextReader); } foreach (var eveSystem in map) { SystemIdToSolarSystem.Add(eveSystem.SolarSystemId, eveSystem); SystemIdToNameDictionary.Add(eveSystem.SolarSystemId, eveSystem.Name); SystemNameToIdDictionary.Add(eveSystem.Name, eveSystem.SolarSystemId); } }