Ejemplo n.º 1
0
        private static void WriteMapList()
        {
            using var tempPath = new TempFileCopy(Path.Combine(path, "Maps.csv"));
            using var tr       = new StreamReader(tempPath.Path) as TextReader;
            using var csv      = new CsvReader(tr, CultureInfo.CurrentCulture);

            var entries = csv.GetRecords <MapEntry>().ToList();
            var mapList = new ClientMapList();

            mapList.MapEntries = new List <ClientMapEntry>();

            foreach (var e in entries)
            {
                mapList.MapEntries.Add(new ClientMapEntry()
                {
                    Code  = e.Code,
                    Name  = e.Name,
                    Music = e.Music
                });
            }

            JsonSerializerOptions options = new JsonSerializerOptions();

            options.SetupExtensions();

            var json = JsonSerializer.Serialize(mapList, options);

            var mapDir = Path.Combine(outPath, "maps.json");

            File.WriteAllText(mapDir, json);
        }
Ejemplo n.º 2
0
        private static List <MapEntry> GetMapList()
        {
            using var tempPath = new TempFileCopy(Path.Combine(path, "Maps.csv"));
            using var tr       = new StreamReader(tempPath.Path) as TextReader;
            using var csv      = new CsvReader(tr, CultureInfo.CurrentCulture);

            return(csv.GetRecords <MapEntry>().ToList());
        }