private void SaveCatalogToFile(List <Book> books) { SaveFileDialog saveDialog = new SaveFileDialog() { Filter = $"{loc.BookCatalog} (*.xlm)|*.xml", }; if (saveDialog.ShowDialog().Value) { ThreadPool.QueueUserWorkItem(_ => { SetLoadingState(true); try { BookCatalogXmlSerializerHelper.Serialize(books, saveDialog.FileName); } catch { // toDo: сделать вывод сообщения об ошибке } finally { SetLoadingState(false); } }); } }
private void LoadCatalogFromFile() { OpenFileDialog openDialog = new OpenFileDialog() { Filter = $"{loc.BookCatalog} (*.xlm)|*.xml", }; if (openDialog.ShowDialog().Value) { ClearSectionsContent(); SetLoadingState(true); ThreadPool.QueueUserWorkItem(_ => { try { var books = BookCatalogXmlSerializerHelper.Deserialize(openDialog.FileName); if (books.Any()) { DistributeBooksToSections(books); } } catch { //toDo: сделать вывод сообщения об ошибке } finally { SetLoadingState(false); } }); } }