예제 #1
0
 public bool ReadAll()
 {
     Helpers.Tekstbestand bestand = new Helpers.Tekstbestand();
     bestand.FileName = ConnectionString;
     if (bestand.Lees())
     {
         string[] books = bestand.Text.Split('\n');
         try
         {
             List <Bll.Book> list = new List <Bll.Book>();
             foreach (string s in books)
             {
                 if (s.Length > 0)
                 {
                     list.Add(ToObject(s));
                 }
             }
             Book.List = list;
             Message   = $"Het bestand {ConnectionString} is gedesialiseerd!";
             return(true);
         }
         catch (Exception e)
         {
             // Melding aan de gebruiker dat iets verkeerd gelopen is.
             // We gebruiken hier de nieuwe mogelijkheid van C# 6: string interpolatie
             Message = $"Bestand {ConnectionString} is niet gedeserialiseerd.\nFoutmelding {e.Message}.";
             return(false);
         }
     }
     else
     {
         Message = $"Bestand {ConnectionString} is niet gedeserialiseerd.\nFoutmelding {bestand.Melding}.";
         return(false);
     }
 }
예제 #2
0
 public static string ReadBooksFromCSVFile()
 {
     Helpers.Tekstbestand bestand = new Helpers.Tekstbestand();
     bestand.FileName = @"Data/Book.csv";
     bestand.Lees();
     return(bestand.Text);
 }
예제 #3
0
 public static string ReadFromCSVFile()
 {
     Helpers.Tekstbestand bestand = new Helpers.Tekstbestand();
     bestand.FileName = @"Data\postcodes.csv";
     bestand.Lees();
     return(bestand.Text);
 }
예제 #4
0
        public static List <Book> DeserializeJsonToList(string fileName)
        {
            Helpers.Tekstbestand bestand = new Helpers.Tekstbestand();
            bestand.FileName = fileName;
            bestand.Lees();
            List <Book> list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Book> >(bestand.Text);

            return(list);
        }
예제 #5
0
        public static List <Postcode> GetPostcodeListFromJson()
        {
            Helpers.Tekstbestand bestand = new Helpers.Tekstbestand();
            bestand.FileName = @"Data/Postcode.json";
            bestand.Lees();
            List <Postcode> list = JsonConvert.DeserializeObject <List <Postcode> >(bestand.Text);

            return(list);
        }
예제 #6
0
 public bool ReadAll()
 {
     try
     {
         Helpers.Tekstbestand bestand = new Helpers.Tekstbestand();
         bestand.FileName = ConnectionString;
         bestand.Lees();
         Postcode.List = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Bll.Postcode> >(bestand.Text);
         Message       = $"Het bestand met de naam {ConnectionString} is met succes geserialiseerd.";
         return(true);
     }
     catch (Exception e)
     {
         // Melding aan de gebruiker dat iets verkeerd gelopen is.
         // We gebruiken hier de nieuwe mogelijkheid van C# 6: string interpolatie
         Message = $"Kan het bestand met de naam {ConnectionString} niet deserialiseren.\nFoutmelding {e.Message}.";
         return(false);
     }
 }