public void testGetContents1() { Book book = new Book(); Resource resource1 = new Resource("id1", System.Text.Encoding.UTF8.GetBytes("Hello, world !"), "chapter1.html", MediatypeService.XHTML); book.getSpine().addResource(resource1); book.getTableOfContents().addSection(resource1, "My first chapter"); Assert.AreEqual(1, book.getContents().Count); }
public void testGetContents3() { Book book = new Book(); Resource resource1 = new Resource("id1", System.Text.Encoding.UTF8.GetBytes("Hello, world !"), "chapter1.html", MediatypeService.XHTML); book.getSpine().addResource(resource1); Resource resource2 = new Resource("id1", System.Text.Encoding.UTF8.GetBytes("Hello, world !"), "chapter2.html", MediatypeService.XHTML); book.getTableOfContents().addSection(resource2, "My first chapter"); book.getGuide().addReference(new GuideReference(resource2, GuideReference.FOREWORD, "The Foreword")); Assert.AreEqual(2, book.getContents().Count); }
/// /// <param name="packageResource"></param> /// <param name="epubReader"></param> /// <param name="book"></param> /// <param name="resources"></param> public static void read(Resource packageResource, EpubReader epubReader, Book book, Resources resources) { XElement packageDocument = XElement.Load(packageResource.getInputStream()); String packageHref = packageResource.getHref(); resources = fixHrefs(packageHref, resources); readGuide(packageDocument, epubReader, book, resources); System.Collections.Generic.Dictionary<string, string> idMapping = new Dictionary<string, string>(); resources = readManifest(packageDocument, packageHref, epubReader, resources, idMapping); book.setResources(resources); readCover(packageDocument, book); // book.setMetadata(PackageDocumentMetadataReader.readMetadata(packageDocument, book.getResources())); book.setSpine(readSpine(packageDocument, epubReader, book.getResources(), idMapping)); // if we did not find a cover page then we make the first page of the book the cover page if (book.getCoverPage() == null && book.getSpine().size() > 0) { book.setCoverPage(book.getSpine().getResource(0)); } }