Class4.cs 1.0 KB

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