JSONDataProvider.cs 991 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace WpfApp3.model
  8. {
  9. public class JSONDataProvider
  10. {
  11. private List<Student> _StudentList;
  12. public JSONDataProvider()
  13. {
  14. var serializer = new DataContractJsonSerializer(typeof(Student[]));
  15. using (var sr = new StreamReader("./test.json"))
  16. {
  17. _StudentList = ((Student[])serializer.ReadObject(sr.BaseStream)).ToList();
  18. }
  19. }
  20. public IEnumerable<Student> getStudents()
  21. {
  22. return _StudentList;
  23. }
  24. }
  25. internal class DataContractJsonSerializer
  26. {
  27. private Type type;
  28. public DataContractJsonSerializer(Type type)
  29. {
  30. this.type = type;
  31. }
  32. internal Student[] ReadObject(Stream baseStream)
  33. {
  34. throw new NotImplementedException();
  35. }
  36. }
  37. }