コード例 #1
0
ファイル: Program.cs プロジェクト: Tydus1/RagnarokRebuild
        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);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Tydus1/RagnarokRebuild
        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());
        }