using System.Collections.Generic;
using WpfApp3.Class;
using System.IO;
using CsvHelper;
using CsvHelper.Configuration;
using System.Linq;
using System.Globalization;
namespace WpfApp3
{
    class InstrumentDataManager
    {
        private List<MusicalInstrument> instruments;

        public InstrumentDataManager()
        {
            instruments = new List<MusicalInstrument>
            {
                new MusicalInstrument { Name = "Гитара", Type = "Струнные", Price = 300 },
                new MusicalInstrument { Name = "Барабаны", Type = "Ударные", Price = 500 },
                new MusicalInstrument { Name = "Фортепиано", Type = "Клавишные", Price = 1000 },
                new MusicalInstrument { Name = "Скрипка", Type = "Струнные", Price = 400 },
                new MusicalInstrument { Name = "Труба", Type = "Медные", Price = 600 },
            };
            CsvConfiguration configuration = new CsvConfiguration(CultureInfo.InvariantCulture)
            {
                Delimiter = ",",
                HasHeaderRecord = true,
                IgnoreBlankLines = true
            };

            using (var reader = new StreamReader("./data.csv"))
            using (var csv = new CsvReader(reader, configuration))
            {
                instruments = csv.GetRecords<MusicalInstrument>().ToList();
            }
        }

        public List<MusicalInstrument> GetInstruments()
        {
            return instruments;
        }
    }
}