/// <summary> /// Save records array to xml file. /// </summary> /// <param name="writer">The xml writer.</param> public void SaveToXML(StreamWriter writer) { if (writer is null) { throw new ArgumentNullException($"{nameof(writer)} cannot be null."); } var collection = new List <SerializableRecord>(); foreach (var record in this.records) { var serializeRecord = new SerializableRecord(); serializeRecord.Id = record.Id; serializeRecord.FirstName = record.FirstName; serializeRecord.LastName = record.LastName; serializeRecord.dateOfBirth = record.DateOfBirth; serializeRecord.Experience = record.Experience; serializeRecord.Account = record.Account; serializeRecord.Gender = record.Gender; collection.Add(serializeRecord); } var serializableRecords = new SerializableCollection(); serializableRecords.SerializeRecords = collection.ToArray(); var xmlWriter = new FileCabinetRecordXmlWriter(XmlWriter.Create(writer), serializableRecords); xmlWriter.Write(); }
private static FileCabinetRecord BuildRecord(SerializableRecord record) => new FileCabinetRecord { Id = record.Id, FirstName = record.FirstName, LastName = record.LastName, DateOfBirth = record.dateOfBirth, Gender = record.Gender, Experience = record.Experience, Account = record.Account, };
private static FileCabinetRecord BuildRecord(SerializableRecord record) { if (record is null) { throw new ArgumentNullException($"{nameof(record)} cannot be null."); } return(new FileCabinetRecord { Id = record.Id, FirstName = record.FirstName, LastName = record.LastName, DateOfBirth = record.DateOfBirth, Experience = record.Eperience, Balance = record.Balance, EnglishLevel = record.EnglishLevel, }); }