public BookCreateEventArgs(Book book)
 {
     Book = book;
 }
示例#2
0
        // Public Methods (5)
        /// <summary>
        /// Retrieves a book object representing the book. This is based on the dtbook.xml file.
        /// </summary>
        /// <param name="bookId"></param>
        /// <returns></returns>
        public Book GetBook(string bookId)
        {
            Book book = null;

            // Get the dtbook xml
            IDirectory bookDirectory = GetBookFolder(bookId);
            if (bookDirectory != null && bookDirectory.Exists)
            {
                IPackage parentPackage = GetPackage(bookId);

                if (parentPackage == null)
                {
                    throw new ArgumentException("No package exists for the given book ID");
                }

                IList<IFile> dtBookFile = bookDirectory.GetFiles(parentPackage.DtBookXmlPath);

                if (dtBookFile.Count == 1)
                {
                    // Set the Xml on the book. Most other properties are derived from this.
                    book = new Book();
                    book.Xml = XDocument.Load(dtBookFile[0].Open(FileMode.Open, FileAccess.Read, FileShare.Read));
                    book.FolderPath = bookDirectory;

                    // Set table of contents (no need for lazy loading as this is too expensive
                    // to do)
                    TableOfContents toc;
                    PageList pages;

                    GetNavStructures(bookId, out toc, out pages);

                    book.TableOfContents = toc;
                    book.PageList = pages;
                }
            }

            return book;
        }