コード例 #1
0
        private void ExportResult(TwoDimArray result)
        {
            Console.WriteLine($"Exporting patched 2da to \"{options.DestFile}\"");
            TwoDimArrayTool tool = TwoDimArrayTool.Start($"-l csv -o \"{options.DestFile}\"");

            using (CsvWriter csvWriter = new CsvWriter(tool.StandardInput, CultureInfo.InvariantCulture))
            {
                csvWriter.WriteRecords(result.Entries.Select(entry => entry.Values).Cast <object>());
            }

            tool.WaitAndCheckExitCode();
        }
コード例 #2
0
        public static TwoDimArray Load2da(string path)
        {
            TextReader      textReader;
            TwoDimArrayTool tool = null;

            if (path.EndsWith(".2da"))
            {
                tool       = TwoDimArrayTool.Start($"-k csv -i \"{path}\"");
                textReader = tool.StandardOutput;
            }
            else
            {
                textReader = File.OpenText(path);
            }

            using CsvReader csvReader = new CsvReader(textReader, CultureInfo.InvariantCulture);
            TwoDimArray twoDimArray = new TwoDimArray(csvReader.GetRecords <dynamic>());

            tool?.WaitAndCheckExitCode();
            return(twoDimArray);
        }