コード例 #1
0
        /// <summary>
        /// Load books from the repo
        /// </summary>
        /// <param name="repo">The repo to load from</param>
        /// <exception cref="ArgumentNullException">Throws when repo is null</exception>
        public void LoadFrom(IBookListStorage repo)
        {
            if (repo == null)
            {
                throw new ArgumentNullException($"{nameof(repo)} must be not null");
            }

            books = new List <Book>(repo.ReadBooks());
        }
コード例 #2
0
        //private IBookListStorage<Book> BookListStorage { get; }

        #endregion

        #region .ctor

        /// <summary>
        /// .ctor
        /// </summary>
        /// <param name="bookListStorage">List of books.</param>

        public BookListService(IBookListStorage <Book> bookListStorage)
        {
            if (bookListStorage == null)
            {
                throw new ArgumentNullException();
            }

            try
            {
                BookList = (List <Book>)bookListStorage.ReadBooks();
            }
            catch (Exception ex)
            {
                throw new BookListServiceException("Unable to download from file: ", ex);
            }
        }