/// <summary> /// Save collection of books in specified storage /// </summary> /// <param name="bookListStorage"></param> /// <exception cref="ArgumentNullException"></exception> public void SaveBooks(IBookListStorage bookListStorage) { if (bookListStorage == null) { throw new ArgumentNullException(); } bookListStorage.Save(Books); }
/// <summary> /// Save list of books to <see cref="storage"/>. /// </summary> /// <param name="storage"> Storage to save the list of books. </param> public void Save(IBookListStorage storage) { if (storage == null) { throw new ArgumentNullException(nameof(storage)); } storage.Save(this.books); }
/// <summary> /// Saving books to binary file /// </summary> /// <param name="storage">Storage provider</param> /// <exception cref="ArgumentNullException">Argument must not be null</exception> public void SaveToStorage(IBookListStorage storage) { if (storage == null) { throw new ArgumentNullException(nameof(storage)); } storage.Save(books); logger.Debug($"List of books saved to the storage"); }
/// <summary> /// Save list of books to the storage. /// </summary> /// <param name="storage"> Storage to save the list of books. </param> public void Save(IBookListStorage storage) { if (storage == null) { this.logger.Error("Refused to store the books. Invalid storage.", new ArgumentNullException(nameof(storage)), storage); throw new ArgumentNullException(nameof(storage)); } storage.Save(this.books); this.logger.Debug("Books were successfully saved in the storage."); }
/// <summary> /// Saves list of books into <see cref="storage"/>. /// </summary> /// <param name="storage"> Storage of the list of books. </param> /// <exception cref="ArgumentNullException">Thrown when storage is null</exception> public void Save(IBookListStorage storage) { if (storage == null) { Logger?.Info("Unhandled ArgumentNullException:"); Logger?.Error("Argument \"storage\" in Save method can't be null."); throw new ArgumentNullException(nameof(storage)); } try { storage.Save(_books); } catch (Exception ex) { Logger?.Info("Unhandled Exception:"); Logger?.Error("Some error while saving books to storage occuried."); throw; } }
/// <summary> /// Save collection of books to storage /// </summary> public void SaveToStorage() { storage.Save(bookList); logger.Info($"Collection of books have saveed to file"); }