C# Class nl.siegmann.epublib.domain.Resources

Show file Open project: lanfengqi/EpubLib-Sharp Class Usage Examples

Public Methods

Method Description
AddAll ( List resources ) : void

Sets the collection of Resources to the given collection of resources

add ( Resource resource ) : Resource

Adds a resource to the resources. Fixes the resources id and href if necessary.

containsByHref ( string href ) : bool

Whether there exists a resource with the given href

containsId ( string id ) : bool

Whether the map of resources already contains a resource with the given id.

findFirstResourceByMediaType ( Resource>.Dictionary resources, MediaType mediaType ) : Resource

Gets the first resource (random order) with the give mediatype. Useful for looking up the table of contents as it's supposed to be the only resource with NCX mediatype.

findFirstResourceByMediaType ( MediaType mediaType ) : Resource

Gets the first resource (random order) with the give mediatype. Useful for looking up the table of contents as it's supposed to be the only resource with NCX mediatype.

fixResourceId ( Resource resource ) : void

Checks the id of the given resource and changes to a unique identifier if it isn't one already.

getAll ( ) : IEnumerable
getAllHrefs ( ) : IEnumerable
getByHref ( string href ) : Resource

Gets the resource with the given href. If the given href contains a fragmentId then that fragment id will be ignored.

getById ( string id ) : Resource

Gets the resource with the given id.

getByIdOrHref ( string idOrHref ) : Resource

First tries to find a resource with as id the given idOrHref, if that fails it tries to find one with the idOrHref as href.

getResourceMap ( ) : Resource>.Dictionary

The resources that make up this book. Resources can be xhtml pages, images, xml documents, etc.

getResourcesByMediaType ( MediaType mediaType ) : List

All resources that have the given MediaType.

getResourcesByMediaTypes ( MediaType mediaTypes ) : List

All Resources that match any of the given list of MediaTypes

isEmpty ( ) : bool
remove ( string href ) : Resource

Remove the resource with the given href.

set ( List resources ) : void

Sets the collection of Resources to the given collection of resources

size ( ) : int

The number of resources

Private Methods

Method Description
createHref ( MediaType mediaType, int counter ) : string
createUniqueResourceId ( Resource resource ) : string

Creates a new resource id that is guarenteed to be unique for this set of Resources

fixResourceHref ( Resource resource ) : void
getResourceItemPrefix ( Resource resource ) : string
makeValidId ( string resourceId, Resource resource ) : string

Check if the id is a valid identifier. if not: prepend with valid identifier

Method Details

AddAll() public method

Sets the collection of Resources to the given collection of resources
public AddAll ( List resources ) : void
resources List A map with as keys the resources href and as values the /// Resources
return void

add() public method

Adds a resource to the resources. Fixes the resources id and href if necessary.
public add ( Resource resource ) : Resource
resource Resource
return Resource

containsByHref() public method

Whether there exists a resource with the given href
public containsByHref ( string href ) : bool
href string
return bool

containsId() public method

Whether the map of resources already contains a resource with the given id.
public containsId ( string id ) : bool
id string
return bool

findFirstResourceByMediaType() public static method

Gets the first resource (random order) with the give mediatype. Useful for looking up the table of contents as it's supposed to be the only resource with NCX mediatype.
public static findFirstResourceByMediaType ( Resource>.Dictionary resources, MediaType mediaType ) : Resource
resources Resource>.Dictionary
mediaType MediaType
return Resource

findFirstResourceByMediaType() public method

Gets the first resource (random order) with the give mediatype. Useful for looking up the table of contents as it's supposed to be the only resource with NCX mediatype.
public findFirstResourceByMediaType ( MediaType mediaType ) : Resource
mediaType MediaType
return Resource

fixResourceId() public method

Checks the id of the given resource and changes to a unique identifier if it isn't one already.
public fixResourceId ( Resource resource ) : void
resource Resource resource
return void

getAll() public method

public getAll ( ) : IEnumerable
return IEnumerable

getAllHrefs() public method

public getAllHrefs ( ) : IEnumerable
return IEnumerable

getByHref() public method

Gets the resource with the given href. If the given href contains a fragmentId then that fragment id will be ignored.
public getByHref ( string href ) : Resource
href string
return Resource

getById() public method

Gets the resource with the given id.
public getById ( string id ) : Resource
id string
return Resource

getByIdOrHref() public method

First tries to find a resource with as id the given idOrHref, if that fails it tries to find one with the idOrHref as href.
public getByIdOrHref ( string idOrHref ) : Resource
idOrHref string
return Resource

getResourceMap() public method

The resources that make up this book. Resources can be xhtml pages, images, xml documents, etc.
public getResourceMap ( ) : Resource>.Dictionary
return Resource>.Dictionary

getResourcesByMediaType() public method

All resources that have the given MediaType.
public getResourcesByMediaType ( MediaType mediaType ) : List
mediaType MediaType
return List

getResourcesByMediaTypes() public method

All Resources that match any of the given list of MediaTypes
public getResourcesByMediaTypes ( MediaType mediaTypes ) : List
mediaTypes MediaType
return List

isEmpty() public method

public isEmpty ( ) : bool
return bool

remove() public method

Remove the resource with the given href.
public remove ( string href ) : Resource
href string
return Resource

set() public method

Sets the collection of Resources to the given collection of resources
public set ( List resources ) : void
resources List resources
return void

size() public method

The number of resources
public size ( ) : int
return int