/// <summary> /// Loads the records from csv file. /// </summary> /// <param name="reader">Csv reader.</param> /// <returns>List of imported records.</returns> public IList <FileCabinetRecord> LoadFromCsv(StreamReader reader) { FileCabinetRecordCsvReader csvReader = new FileCabinetRecordCsvReader(reader); IList <FileCabinetRecord> records = csvReader.ReadAll(); return(records); }
/// <summary> /// Loads records from csv file. /// </summary> /// <param name="stream">Current stream.</param> /// <returns>Count loaded records.</returns> internal int LoadFromCsv(StreamReader stream) { FileCabinetRecordCsvReader reader = new FileCabinetRecordCsvReader(stream); this.records = reader.ReadAll().ToArray(); return(this.records.Length); }
/// <summary> /// Loads from the CSV file. /// </summary> /// <param name="reader">Stream to read.</param> /// <returns>Count of records.</returns> public int LoadFromCsv(StreamReader reader) { var csvReader = new FileCabinetRecordCsvReader(reader); this.records = csvReader.ReadAll(); return(this.records.Count); }
/// <summary> /// Метод выгрузки из csv. /// </summary> /// <param name="fs">Filestream.</param> public void LoadFromCsv(FileStream fs) { StreamReader reader = new StreamReader(fs); FileCabinetRecordCsvReader csvReader = new FileCabinetRecordCsvReader(reader); List <FileCabinetRecord> list = new List <FileCabinetRecord>(csvReader.ReadAll()); this.records = list.ToArray(); }
/// <summary>Loads records from CSV file.</summary> /// <param name="reader">Reader.</param> /// <param name="validator">Validator.</param> /// <exception cref="ArgumentNullException">Thrown when reader or validator is null.</exception> public void LoadFromCsv(StreamReader reader, IRecordValidator validator) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } if (validator == null) { throw new ArgumentNullException(nameof(validator)); } var csvReader = new FileCabinetRecordCsvReader(reader); IList <FileCabinetRecord> records; try { records = csvReader.ReadAll(); } catch (FormatException) { throw; } catch (IndexOutOfRangeException) { throw; } UnverifiedData unverifiedData; foreach (var record in records) { unverifiedData = new UnverifiedData(record); try { validator.ValidateParameters(unverifiedData); } catch (ArgumentException ex) { this.invalidRecords.Add(new Tuple <FileCabinetRecord, string>(record, ex.Message)); continue; } this.records.Add(record); } }
/// <summary> /// This Methods load from file in csv-format. /// </summary> /// <param name="streamReader">Represents characters read.</param> /// <returns>List records.</returns> public IList <FileCabinetRecord> LoadFromCsv(StreamReader streamReader) { FileCabinetRecordCsvReader csvReader = new FileCabinetRecordCsvReader(streamReader); return(csvReader.ReadAll()); }
/// <summary> /// Load records from CSV file. /// </summary> /// <param name="reader">StreamReader.</param> public void LoadFromCsv(StreamReader reader) { FileCabinetRecordCsvReader fileCabinetRecordCsvReader = new FileCabinetRecordCsvReader(reader); this.Records = fileCabinetRecordCsvReader.ReadAll(); }
/// <summary> /// Load records from csv file. /// </summary> /// <param name="reader">Stream Reader.</param> public void LoadFromCsv(StreamReader reader) { FileCabinetRecordCsvReader csvReader = new FileCabinetRecordCsvReader(reader); this.records = csvReader.ReadAll().ToArray(); }