/// <summary>
        /// Finds books according to tag
        /// </summary>
        /// <param name="tag">Object that contains a rule of searching</param>
        /// <returns>New <see cref="BookListService"/> object with specified books</returns>
        public BookListService FindBookByTag(ITagContainer tag)
        {
            if (ReferenceEquals(tag, null))
            {
                throw new ArgumentNullException();
            }
            BookListService temp = new BookListService(this.logger);

            foreach (var t in bookList)
            {
                if (tag.Contain(t))
                {
                    temp.AddBook(t);
                }
            }

            return(temp);
        }
Esempio n. 2
0
        /// <summary>
        /// Finds a book by a given criterion
        /// </summary>
        /// <param name="tag">search criteria</param>
        /// <returns>list of matching books</returns>
        public List <Book> FindBookByTag(ITagContainer tag)
        {
            if (tag == null)
            {
                throw new ArgumentNullException("Tag must be not null");
            }
            List <Book> temp  = new List <Book>();
            List <Book> books = GetAllBooks();

            foreach (var book in books)
            {
                if (tag.Contain(book))
                {
                    temp.Add(book);
                }
            }
            logger.Debug("Book was found");
            return(temp);
        }