Example #1
0
 public static BookManager Load(string filePath = null)
 {
     try {
         filePath = filePath == null ? DefaultFilePath : filePath;
         string json             = File.ReadAllText(filePath);
         BookManagerTemplate bmt = JsonSerializer.Deserialize <BookManagerTemplate>(json);
         BookManager         bm  = BookManager.Create(bmt.Password, filePath);
         bm.books = bmt.Books;
         return(bm);
     } catch (Exception e) {
     }
     return(null);
 }
Example #2
0
 public bool Save()
 {
     try {
         BookManagerTemplate bmt = new BookManagerTemplate();
         bmt.Password = this.Password;
         bmt.Books    = this.books;
         string json = JsonSerializer.Serialize <BookManagerTemplate>(bmt);
         File.WriteAllText(this.FilePath, json);
         return(true);
     } catch (Exception) {
     }
     return(false);
 }