예제 #1
0
        public XElement ToXML()
        {
            var xPublishInfo = new XElement(Fb2Const.fb2DefaultNamespace + PublishInfoElementName);

            if (BookTitle != null)
            {
                xPublishInfo.Add(BookTitle.ToXML(BookNameElementName));
            }
            if (Publisher != null)
            {
                xPublishInfo.Add(Publisher.ToXML(PublisherElementName));
            }
            if (City != null)
            {
                xPublishInfo.Add(City.ToXML(CityElementName));
            }
            if (Year != null)
            {
                xPublishInfo.Add(new XElement(Fb2Const.fb2DefaultNamespace + YearElementName, Year.ToString()));
            }
            if (ISBN != null)
            {
                xPublishInfo.Add(ISBN.ToXML(ISBNElementName));
            }
            foreach (SequenceType sec in ItemSequences)
            {
                xPublishInfo.Add(sec.ToXML());
            }

            return xPublishInfo;
        }
예제 #2
0
        public XElement ToXML(string NameElement)
        {
            XElement xTitleInfo = new XElement(Fb2Const.fb2DefaultNamespace + NameElement);

            foreach (TitleGenreType genre in genres)
            {
                try
                {
                    xTitleInfo.Add(genre.ToXML());
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(string.Format("Error converting genre data to XML: {0}", ex.Message));
                    continue;
                }
            }
            foreach (AuthorType author in bookAuthors)
            {
                try
                {
                    xTitleInfo.Add(author.ToXML());
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(string.Format("Error converting genre data to XML: {0}", ex.Message));
                    continue;
                }
            }

            if (BookTitle != null)
            {
                xTitleInfo.Add(BookTitle.ToXML(BookTitleElementName));
            }

            if (Annotation != null)
            {
                xTitleInfo.Add(Annotation.ToXML());
            }
            if (Keywords != null)
            {
                xTitleInfo.Add(Keywords.ToXML(KeywordsElementName));
            }
            if (BookDate != null)
            {
                xTitleInfo.Add(BookDate.ToXML());
            }
            if (Cover != null)
            {
                xTitleInfo.Add(Cover.ToXML());
            }
            if (!string.IsNullOrEmpty(Language))
            {
                xTitleInfo.Add(new XElement(Fb2Const.fb2DefaultNamespace + LanguageElementName, Language));
            }
            if (!string.IsNullOrEmpty(SrcLanguage))
            {
                xTitleInfo.Add(new XElement(Fb2Const.fb2DefaultNamespace + SourceLanguageElementName, SrcLanguage));
            }
            foreach (AuthorType translat in translators)
            {
                xTitleInfo.Add(translat.ToXML());
            }
            foreach (SequenceType sec in sequences)
            {
                xTitleInfo.Add(sec.ToXML());
            }

            return(xTitleInfo);
        }