示例#1
0
		public NavPoint(string id, string title, string source, int order, ContentData contentData, List<NavPoint> children) {
			ID = id;
			Title = title;
			Source = source;
			Order = order;
			ContentData = contentData;
			Children = children;
		}
示例#2
0
        private void LoadEpubMetaDataFromOpfFile(string opfFilePath)
        {
            ZipEntry zipEntry = _EpubFile.Entries.FirstOrDefault(e => e.FileName.Equals(opfFilePath, StringComparison.InvariantCultureIgnoreCase));

            if (zipEntry == null)
            {
                throw new Exception("Invalid epub file.");
            }

            // NEW By Volkoye
            OpfFile = new ContentData(opfFilePath, zipEntry);

            XElement contentOpf;

            using (MemoryStream memoryStream = new MemoryStream()) {
                zipEntry.Extract(memoryStream);
                memoryStream.Position = 0;
                contentOpf            = XElement.Load(memoryStream);
            }

            XNamespace xNamespace = contentOpf.Attribute("xmlns") != null?contentOpf.Attribute("xmlns").Value : XNamespace.None;

            string uniqueIdentifier = contentOpf.Attribute("unique-identifier").Value;

            UUID = contentOpf.Elements(xNamespace + "metadata").Elements().FirstOrDefault(e => e.Name.LocalName == "identifier" && e.Attribute("id") != null && e.Attribute("id").Value == uniqueIdentifier).Value;
            foreach (var metadataElement in contentOpf.Elements(xNamespace + "metadata").Elements().Where(e => e.Value.Trim() != string.Empty))
            {
                switch (metadataElement.Name.LocalName)
                {
                case "title": Title.Add(metadataElement.Value); break;

                case "creator": Creator.Add(metadataElement.Value); break;

                case "date":
                    var attribute = metadataElement.Attributes().FirstOrDefault(a => a.Name.LocalName == "event");
                    if (attribute != null)
                    {
                        Date.Add(new DateData(attribute.Value, metadataElement.Value));
                    }
                    break;

                case "publisher": Publisher.Add(metadataElement.Value); break;

                case "subject": Subject.Add(metadataElement.Value); break;

                case "source": Source.Add(metadataElement.Value); break;

                case "rights": Rights.Add(metadataElement.Value); break;

                case "description": Description.Add(metadataElement.Value); break;

                case "contributor": Contributer.Add(metadataElement.Value); break;

                case "type": Type.Add(metadataElement.Value); break;

                case "format": Format.Add(metadataElement.Value); break;

                case "identifier": ID.Add(metadataElement.Value); break;

                case "language": Language.Add(metadataElement.Value); break;

                case "relation": Relation.Add(metadataElement.Value); break;

                case "coverage": Coverage.Add(metadataElement.Value); break;
                }
            }

            LoadManifestSectionFromOpfFile(contentOpf, xNamespace);
        }