Exemple #1
0
        /// <summary>
        /// Read the records from xml file.
        /// </summary>
        /// <param name="reader">The xml reader.</param>
        public void LoadFromXml(StreamReader reader)
        {
            if (reader is null)
            {
                throw new ArgumentNullException($"{nameof(reader)} cannot be null.");
            }

            using var xmlReader = new FileCabinetRecordXmlReader(reader);
            this.records        = xmlReader.Read().ToArray();
        }
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="stream">The stream.</param>
        public void LoadFromXml(StreamReader stream)
        {
            FileCabinetRecordXmlReader xmlReader = new FileCabinetRecordXmlReader(stream);

            this.Records = new ReadOnlyCollection <FileCabinetRecord>(xmlReader.ReadAll());
        }
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="validator">The validator.</param>
        /// <param name="modelWriter">console writer.</param>
        public void LoadFromXml(StreamReader reader, IRecordValidator validator, ModelWriters modelWriter)
        {
            FileCabinetRecordXmlReader xmlReader = new FileCabinetRecordXmlReader(reader, validator, modelWriter);

            this.ReadRecords = xmlReader.ReadAll();
        }