nl.siegmann.epublib.domain.Resources.remove C# (CSharp) Method

remove() public method

Remove the resource with the given href.
public remove ( string href ) : Resource
href string
return Resource
        public Resource remove(string href)
        {
            Resource resource = resources[href];
            if (resource != null)
            {
                resources.Remove(href);
                return resource;
            }
            return null;
        }

Usage Example

        /// <summary>
        /// Reads the manifest containing the resource ids, hrefs and mediatypes.
        /// </summary>
        /// <param>book</param>
        /// <param>resourcesByHref</param>
        /// <param>a Map with resources, with their id's as key.</param>
        /// <param name="packageDocument"></param>
        /// <param name="packageHref"></param>
        /// <param name="epubReader"></param>
        /// <param name="resources"></param>
        /// <param name="idMapping"></param>
        private static Resources readManifest(XElement packageDocument, String packageHref, EpubReader epubReader, Resources resources, Dictionary<String, String> idMapping)
        {
            XElement manifestElement = DOMUtil.getFirstElementByTagNameNS(packageDocument, NAMESPACE_OPF, OPFTags.manifest);
            Resources result = new Resources();
            if (manifestElement == null)
            {
                return result;
            }
            var itemElements = packageDocument.Elements(NAMESPACE_OPF + OPFTags.item).Elements<XElement>();

            foreach (XElement itemElement in (from e in itemElements where e.Value.Trim() != string.Empty select e))
            {
                String id = DOMUtil.getAttribute(itemElement, OPFAttributes.id);
                String href = DOMUtil.getAttribute(itemElement, OPFAttributes.href);
                try
                {
                    href = System.Web.HttpUtility.UrlDecode(href, System.Text.Encoding.GetEncoding(Constants.ENCODING));
                }
                catch (Exception e)
                {
                    //log.error(e.getMessage());
                }
                String mediaTypeName = DOMUtil.getAttribute(itemElement, OPFAttributes.media_type);
                Resource resource = resources.remove(href);
                if (resource == null)
                {
                    //log.error("resource with href '" + href + "' not found");
                    continue;
                }
                resource.setId(id);
                MediaType mediaType = MediatypeService.getMediaTypeByName(mediaTypeName);
                if (mediaType != null)
                {
                    resource.setMediaType(mediaType);
                }
                result.add(resource);
                idMapping.Add(id, resource.getId());
            }
            return result;
        }
All Usage Examples Of nl.siegmann.epublib.domain.Resources::remove