Пример #1
0
        internal static Book ParseBook(XElement root, XElement xmlBook)
        {
            var book = new Book();
            book.ID = xmlBook.Element("id").IntValue();
            book.Title = xmlBook.Element("title").Value;
            book.CoverLink = xmlBook.Element("image_url").Value;
            book.CoverSmallLink = xmlBook.Element("small_image_url").Value;
            book.Authors.AddRange(from author in xmlBook.Descendants("author")
                                  select new Author(author.Element("name").Value, author.Element("id").IntValue()));
            book.OriginalPublicationDate = ParseDate(root, true);
            book.RatingsCount = root.Element("ratings_count").IntValue();
            book.AverageRating = root.Element("average_rating").DoubleValue();

            return book;
        }
Пример #2
0
 internal static Book ParseBookInfo(XElement xmlBook)
 {
     var book = new Book();
     book.ID = xmlBook.Element("id").IntValue();
     book.Isbn10 = xmlBook.Element("isbn").Value;
     book.Isbn13 = xmlBook.Element("isbn13").Value;
     book.Title = xmlBook.Element("title").Value;
     book.CoverLink = xmlBook.Element("image_url").Value;
     book.CoverSmallLink = xmlBook.Element("small_image_url").Value;
     book.Link = xmlBook.Element("link").Value;
     book.PagesCount = xmlBook.Element("num_pages").IntValue();
     book.Format = xmlBook.Element("format").Value;
     book.Edition = xmlBook.Element("edition_information").Value;
     book.Publisher = xmlBook.Element("publisher").Value;
     book.PublicationDate = ParseDate(xmlBook, false);
     book.AverageRating = xmlBook.Element("average_rating").DoubleValue();
     book.RatingsCount = xmlBook.Element("ratings_count").IntValue();
     book.Description = Regex.Replace(Regex.Replace(xmlBook.Element("description").Value, "<br />", Environment.NewLine), "<.+?>", "");
     book.OriginalPublicationDate = ParseDate(xmlBook.Element("work"), true);
     book.Authors.AddRange(from author in xmlBook.Elements("authors").Elements("author")
                           select ParseAuthorBasic(author));
     book.Series = (from series in xmlBook.Descendants("series")
                   select ParseSeriesBasic(series)).FirstOrDefault();
     return book;
 }