Exemplo n.º 1
0
 public async void Serialize(string nameShelf, ShelfListBook listBook)
 {
     using (FileStream Writer = new FileStream($"LocalResources/ShelfData/{nameShelf}.json", FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite))
     {
         await JsonSerializer.SerializeAsync <ShelfListBook>(Writer, listBook);
     }
 }
Exemplo n.º 2
0
        public ShelfListBook DeserializeShelfListBook(string nameShelf)
        {
            if (File.Exists($"LocalResources/ShelfData/{nameShelf}.json"))
            {
                using (StreamReader Reader = new StreamReader($"LocalResources/ShelfData/{nameShelf}.json"))
                {
                    JsonResult = Reader.ReadToEnd();
                    ListBook   = JsonSerializer.Deserialize <ShelfListBook>(JsonResult);
                }
            }
            else
            {
                ListBook = new ShelfListBook();
            }

            return(ListBook);
        }
Exemplo n.º 3
0
 public async void Delete(string nameShelf, ShelfListBook listBook)
 {
     File.Delete($"LocalResources/ShelfData/{nameShelf}.json");
     Serialize(nameShelf, listBook);
 }