Class4.cs 893 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Formats.Asn1;
  5. using System.Globalization;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using CsvHelper;
  11. namespace WpfApp4.model
  12. {
  13. public class CSVDataProvider : LocalDataProvider,IDataProvider
  14. {
  15. private List<Hero> HeroList;
  16. // конструктор класса
  17. public CSVDataProvider()
  18. {
  19. using (var reader = new StreamReader("./data.csv"))
  20. {
  21. using (var csv = new CsvReader(
  22. reader,
  23. CultureInfo.InvariantCulture))
  24. {
  25. HeroList = csv.GetRecords<Hero>().ToList();
  26. }
  27. }
  28. }
  29. public IEnumerable<Hero> getHero()
  30. {
  31. return HeroList;
  32. }
  33. }
  34. }