public static void Write(Type type, string path, IEnumerable <object> records)
 {
     try
     {
         using var writer    = new StreamWriter(path, false, EncodesResolver.Resolve(type));
         using var csvWriter = new CsvHelper.CsvWriter(writer, CultureInfo.InvariantCulture);
         csvWriter.Configuration.HasHeaderRecord = CsvHasHeaderResolver.Resolve(type);
         csvWriter.WriteRecords(records);
     }
     catch (IOException ex)
     {
         throw new CsvIOException("CSVファイルに書き込めません", ex);
     }
     catch (Exception ex)
     {
         throw new CsvIOException("CSVファイルの書き込み時に不明なエラーが発生しました", ex);
     }
 }
 public static IEnumerable <object> Read(Type type, string path)
 {
     try
     {
         using var reader    = new StreamReader(path, EncodesResolver.Resolve(type));
         using var csvReader = new CsvHelper.CsvReader(reader, CultureInfo.InvariantCulture);
         csvReader.Configuration.HasHeaderRecord = CsvHasHeaderResolver.Resolve(type);
         return(csvReader.GetRecords(type).ToList());
     }
     catch (Exception ex) when(ex is ValidationException || ex is BadDataException)
     {
         throw new CsvIOException("CSVファイルの書式が不正です", ex);
     }
     catch (IOException ex)
     {
         throw new CsvIOException("CSVファイルを読み込めません", ex);
     }
     catch (Exception ex)
     {
         throw new CsvIOException("CSVファイル読み込み時に不明なエラーが発生しました", ex);
     }
 }