1234567891011121314151617181920212223242526272829303132333435363738 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Formats.Asn1;
- using System.Globalization;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using CsvHelper;
- namespace WpfApp4.model
- {
- public class CSVDataProvider : LocalDataProvider,IDataProvider
- {
- private List<Hero> HeroList;
- // конструктор класса
- public CSVDataProvider()
- {
- using (var reader = new StreamReader("./data.csv"))
- {
- using (var csv = new CsvReader(
- reader,
- CultureInfo.InvariantCulture))
- {
- HeroList = csv.GetRecords<Hero>().ToList();
- }
- }
- }
- public IEnumerable<Hero> getHero()
- {
- return HeroList;
- }
- }
- }
|