nl.siegmann.epublib.domain.Book.getContents C# (CSharp) Method

getContents() public method

All Resources of the Book that can be reached via the Spine, the TableOfContents or the Guide.

Consists of a list of "reachable" resources:

  • The coverpage
  • The resources of the Spine that are not already in the result
  • The resources of the Table of Contents that are not already in the result
  • The resources of the Guide that are not already in the result
To get all html files that make up the epub file use
public getContents ( ) : List
return List
        public List<Resource> getContents()
        {
            Dictionary<String, Resource> result = new Dictionary<String, Resource>();
            addToContentsResult(getCoverPage(), result);

            foreach (SpineReference spineReference in getSpine().getSpineReferences())
            {
                addToContentsResult(spineReference.getResource(), result);
            }

            foreach (Resource resource in getTableOfContents().getAllUniqueResources())
            {
                addToContentsResult(resource, result);
            }

            foreach (GuideReference guideReference in getGuide().getReferences())
            {
                addToContentsResult(guideReference.getResource(), result);
            }
            return new List<Resource>(result.Values);
        }

Usage Example

Example #1
0
 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);
 }
All Usage Examples Of nl.siegmann.epublib.domain.Book::getContents