/// <summary>Saves snapshot to CSV format.</summary> /// <param name="sr">The stream for a file.</param> public void SaveToCsv(StreamWriter sr) { FileCabinetRecordCsvWriter writer = new FileCabinetRecordCsvWriter(sr); for (int i = 0; i < this.records.Length; i++) { writer.Write(this.records[i]); } }
/// <summary> /// Writes data in Csv file. /// </summary> /// <param name="streamWriter">Provider for writing.</param> public void SaveToCsv(StreamWriter streamWriter) { FileCabinetRecordCsvWriter csvWriter = new FileCabinetRecordCsvWriter(streamWriter); foreach (var record in this.records) { csvWriter.Write(record); } }
/// <summary> /// Saves the records to csv file. /// </summary> /// <param name="writer">Csv writer.</param> /// <returns>Whether operation succeeded.</returns> public bool SaveToCsv(StreamWriter writer) { FileCabinetRecordCsvWriter csvWriter = new FileCabinetRecordCsvWriter(writer); foreach (var record in this.Records) { csvWriter.Write(record); } return(true); }
public void SaveToCsv(StreamWriter streamWriter) { var csvWriter = new FileCabinetRecordCsvWriter(streamWriter); csvWriter.WriteString("Id,First name,Last name,Date of birth,Age,Money,Letter"); foreach (var record in records) { csvWriter.Write(record); } }
/// <summary> /// Save records to .csv file. /// </summary> /// <param name="stream">Stream.</param> public void SaveToCsv(FileStream stream) { using (StreamWriter writer = new StreamWriter(stream)) { FileCabinetRecordCsvWriter fileCabinetRecordCsvWriter = new FileCabinetRecordCsvWriter(writer); for (int i = 0; i < this.records.Length; i++) { fileCabinetRecordCsvWriter.Write(this.records[i]); } } }
private void WriteAllRecordsCsv(StreamWriter textWriter, FileCabinetRecord[] records) { var csvWriter = new FileCabinetRecordCsvWriter(textWriter); string fieldsName = "Id,First Name,Last Name,Date of Birth,Cabinet Number,Salary,Category"; textWriter.WriteLine(fieldsName); foreach (var item in records) { csvWriter.Write(item); } }
/// <summary> /// Saves records to csv file. /// </summary> /// <param name="writer">Streamwriter to save records.</param> /// <exception cref="ArgumentNullException">Writer must be not null.</exception> public void SaveToCsv(StreamWriter writer) { if (writer is null) { throw new ArgumentNullException(nameof(writer), Configurator.GetConstantString("NullStream")); } using FileCabinetRecordCsvWriter csvWriter = new FileCabinetRecordCsvWriter(writer); foreach (var record in this.records) { csvWriter.Write(record); } }
/// <summary>Saves snapshot to csv file.</summary> /// <param name="writer">Writer.</param> /// <exception cref="ArgumentNullException">Thrown when writer is null.</exception> public void SaveToCsv(StreamWriter writer) { if (writer == null) { throw new ArgumentNullException(nameof(writer)); } var csvWriter = new FileCabinetRecordCsvWriter(writer); writer.WriteLine("Id;First Name;Last Name;Date of Birth;Sex;Number of Reviews;Salary"); foreach (var record in this.records) { csvWriter.Write(record); } }
/// <summary> /// Saves to the CSV file. /// </summary> /// <param name="writer">Stream to write.</param> public void SaveToCsv(StreamWriter writer) { var csvWriter = new FileCabinetRecordCsvWriter(writer); csvWriter.Write(this.records); }
/// <summary> /// Save snapshot to CSV file. /// </summary> /// <param name="writer"> Get writer.</param> public void SaveToCSV(FileCabinetRecordCsvWriter writer) { writer.Write(this.records); }
/// <summary> /// Метод записи в csv. /// </summary> /// <param name="streamWriter">StreamWriter.</param> public void SaveToCsv(StreamWriter streamWriter) { FileCabinetRecordCsvWriter fileCabinetRecordCsvWriter = new FileCabinetRecordCsvWriter(streamWriter); fileCabinetRecordCsvWriter.Write(this.records); }