public static void Convert(ItemTitleInfo titleInfo, IBookInformationData titleInformation, IEPubConversionSettings settings)
 {
     foreach (var genre in titleInfo.Genres)
     {
         var item = new Subject
         {
             SubjectInfo = Rus2Lat.Instance.Translate(DescriptionConverters.Fb2GenreToDescription(genre.Genre),
                                                      settings.TransliterationSettings)
         };
         titleInformation.Subjects.Add(item);
     }
 }
 public static void Convert(ItemTitleInfo titleInfo, IBookInformationData titleInformation, IEPubConversionSettings settings)
 {
     foreach (var translator in titleInfo.Translators)
     {
         var person = new PersoneWithRole
         {
             PersonName = Rus2Lat.Instance.Translate(DescriptionConverters.GenerateAuthorString(translator, settings),
                                                     settings.TransliterationSettings),
             FileAs   = DescriptionConverters.GenerateFileAsString(translator, settings),
             Role     = RolesEnum.Translator,
             Language = titleInfo.Language
         };
         titleInformation.Contributors.Add(person);
     }
 }
 public static void Convert(ItemTitleInfo itemInfo, IBookInformationData titleInformation)
 {
     foreach (var seq in itemInfo.Sequences)
     {
         List <string> allSequences = DescriptionConverters.GetSequencesAsStrings(seq);
         if (allSequences.Count != 0)
         {
             foreach (var sequence in allSequences)
             {
                 titleInformation.Series.Add(sequence);
                 titleInformation.AllSequences.Add(sequence);
             }
         }
     }
 }
        private void ConvertMainTitle(ItemTitleInfo titleInfo, IBookInformationData titleInformation)
        {
            var bookTitle = new Title
            {
                TitleName = Rus2Lat.Instance.Translate(DescriptionConverters.FormatBookTitle(titleInfo, _conversionSettings),
                                                       _conversionSettings.TransliterationSettings),
                Language = string.IsNullOrEmpty(titleInfo.BookTitle.Language)
                    ? titleInfo.Language
                    : titleInfo.BookTitle.Language,
                TitleType = TitleType.Main
            };

            titleInformation.BookTitles.Add(bookTitle);
            // add main title language
            titleInformation.Languages.Add(titleInfo.Language);
        }
        public static void Convert(ItemTitleInfo titleInfo, IEPubConversionSettings settings, IBookInformationData titleInformation)
        {
            foreach (var author in titleInfo.BookAuthors)
            {
                var    person       = new PersoneWithRole();
                string authorString = DescriptionConverters.GenerateAuthorString(author, settings);
                person.PersonName = Rus2Lat.Instance.Translate(authorString, settings.TransliterationSettings);
                person.FileAs     = DescriptionConverters.GenerateFileAsString(author, settings);
                person.Role       = RolesEnum.Author;
                person.Language   = titleInfo.Language;
                titleInformation.Creators.Add(person);

                // add authors to Title page
                titleInformation.Authors.Add(authorString);
            }
        }
        public void Convert(FB2File fb2File, IBookInformationData titleInformation)
        {
            if ((fb2File.DocumentInfo.SourceOCR != null) && !string.IsNullOrEmpty(fb2File.DocumentInfo.SourceOCR.Text))
            {
                titleInformation.Source = new Source {
                    SourceData = fb2File.DocumentInfo.SourceOCR.Text
                };
            }

            foreach (var docAuthor in fb2File.DocumentInfo.DocumentAuthors)
            {
                var person = new PersoneWithRole
                {
                    PersonName =
                        Rus2Lat.Instance.Translate(DescriptionConverters.GenerateAuthorString(docAuthor, _conversionSettings), _conversionSettings.TransliterationSettings),
                    FileAs = DescriptionConverters.GenerateFileAsString(docAuthor, _conversionSettings),
                    Role   = RolesEnum.Adapter
                };
                if (fb2File.TitleInfo != null)
                {
                    person.Language = fb2File.TitleInfo.Language;
                }
                titleInformation.Contributors.Add(person);
            }

            // Getting information from FB2 Source Title Info section
            if (!SourceDataInclusionControl.Instance.IsIgnoreInfoSource(SourceDataInclusionControl.DataTypes.Source, _conversionSettings.IgnoreTitle) &&
                (fb2File.SourceTitleInfo.BookTitle != null) &&
                !string.IsNullOrEmpty(fb2File.SourceTitleInfo.BookTitle.Text))
            {
                var bookTitle = new Title
                {
                    TitleName =
                        Rus2Lat.Instance.Translate(fb2File.SourceTitleInfo.BookTitle.Text,
                                                   _conversionSettings.TransliterationSettings),
                    Language =
                        string.IsNullOrEmpty(fb2File.SourceTitleInfo.BookTitle.Language) &&
                        (fb2File.TitleInfo != null)
                                ? fb2File.TitleInfo.Language
                                : fb2File.SourceTitleInfo.BookTitle.Language,
                    TitleType = TitleType.SourceInfo
                };
                titleInformation.BookTitles.Add(bookTitle);
                titleInformation.Languages.Add(fb2File.SourceTitleInfo.Language);
            }

            // add authors
            foreach (var author in fb2File.SourceTitleInfo.BookAuthors)
            {
                var person = new PersoneWithRole
                {
                    PersonName =
                        Rus2Lat.Instance.Translate(DescriptionConverters.GenerateAuthorString(author, _conversionSettings),
                                                   _conversionSettings.TransliterationSettings),
                    FileAs   = DescriptionConverters.GenerateFileAsString(author, _conversionSettings),
                    Role     = RolesEnum.Author,
                    Language = fb2File.SourceTitleInfo.Language
                };
                titleInformation.Creators.Add(person);
            }

            TranslatorsInfoConverterV2.Convert(fb2File.SourceTitleInfo, titleInformation, _conversionSettings);
            GenresInfoConverterV2.Convert(fb2File.SourceTitleInfo, titleInformation, _conversionSettings);
        }
        public HTMLItem Convert(FB2File fb2File, ConverterOptionsV3 settings)
        {
            if (fb2File == null)
            {
                throw new ArgumentNullException("fb2File");
            }
            var info   = new Div(HTMLElementType.HTML5);
            var header = new H3(HTMLElementType.HTML5);

            header.Add(new SimpleHTML5Text(HTMLElementType.HTML5)
            {
                Text = "FB2 document info"
            });
            info.Add(header);
            if (fb2File.DocumentInfo != null)
            {
                if (!string.IsNullOrEmpty(fb2File.DocumentInfo.ID))
                {
                    var p = new Paragraph(HTMLElementType.HTML5);
                    p.Add(new SimpleHTML5Text(HTMLElementType.HTML5)
                    {
                        Text = string.Format("Document ID:  {0}", fb2File.DocumentInfo.ID)
                    });
                    info.Add(p);
                }
                if (fb2File.DocumentInfo.DocumentVersion.HasValue)
                {
                    var p = new Paragraph(HTMLElementType.HTML5);
                    p.Add(new SimpleHTML5Text(HTMLElementType.HTML5)
                    {
                        Text = string.Format("Document version:  {0}", fb2File.DocumentInfo.DocumentVersion)
                    });
                    info.Add(p);
                }
                if ((fb2File.DocumentInfo.DocumentDate != null) && !string.IsNullOrEmpty(fb2File.DocumentInfo.DocumentDate.Text))
                {
                    var p = new Paragraph(HTMLElementType.HTML5);
                    p.Add(new SimpleHTML5Text(HTMLElementType.HTML5)
                    {
                        Text = string.Format("Document creation date:  {0}", fb2File.DocumentInfo.DocumentDate.Text)
                    });
                    info.Add(p);
                }
                if ((fb2File.DocumentInfo.ProgramUsed2Create != null) && !string.IsNullOrEmpty(fb2File.DocumentInfo.ProgramUsed2Create.Text))
                {
                    var p = new Paragraph(HTMLElementType.HTML5);
                    p.Add(new SimpleHTML5Text(HTMLElementType.HTML5)
                    {
                        Text = string.Format("Created using:  {0} software", fb2File.DocumentInfo.ProgramUsed2Create.Text)
                    });
                    info.Add(p);
                }
                if ((fb2File.DocumentInfo.SourceOCR != null) && !string.IsNullOrEmpty(fb2File.DocumentInfo.SourceOCR.Text))
                {
                    var p = new Paragraph(HTMLElementType.HTML5);
                    p.Add(new SimpleHTML5Text(HTMLElementType.HTML5)
                    {
                        Text = string.Format("OCR Source:  {0}", fb2File.DocumentInfo.SourceOCR.Text)
                    });
                    info.Add(p);
                }
                if ((fb2File.DocumentInfo.DocumentAuthors != null) && (fb2File.DocumentInfo.DocumentAuthors.Count > 0))
                {
                    var heading = new H4(HTMLElementType.HTML5);
                    heading.Add(new SimpleHTML5Text(HTMLElementType.HTML5)
                    {
                        Text = "Document authors :"
                    });
                    info.Add(heading);
                    var authors = new UnorderedList(HTMLElementType.HTML5);
                    foreach (var author in fb2File.DocumentInfo.DocumentAuthors)
                    {
                        var li = new ListItem(HTMLElementType.HTML5);
                        li.Add(new SimpleHTML5Text(HTMLElementType.HTML5)
                        {
                            Text = DescriptionConverters.GetAuthorAsSting(author)
                        });
                        authors.Add(li);
                    }
                    info.Add(authors);
                }
                if ((fb2File.DocumentInfo.DocumentPublishers != null) && (fb2File.DocumentInfo.DocumentPublishers.Count > 0))
                {
                    var heading = new H4(HTMLElementType.HTML5);
                    heading.Add(new SimpleHTML5Text(HTMLElementType.HTML5)
                    {
                        Text = "Document publishers :"
                    });
                    info.Add(heading);

                    var publishers = new UnorderedList(HTMLElementType.HTML5);
                    foreach (var publisher in fb2File.DocumentInfo.DocumentPublishers)
                    {
                        var li = new ListItem(HTMLElementType.HTML5);
                        li.Add(new SimpleHTML5Text(HTMLElementType.HTML5)
                        {
                            Text = DescriptionConverters.GetAuthorAsSting(publisher)
                        });
                        publishers.Add(li);
                    }
                    info.Add(publishers);
                }

                if ((fb2File.DocumentInfo.SourceURLs != null) && (fb2File.DocumentInfo.SourceURLs.Any()))
                {
                    var heading = new H4(HTMLElementType.HTML5);
                    heading.Add(new SimpleHTML5Text(HTMLElementType.HTML5)
                    {
                        Text = "Source URLs :"
                    });
                    info.Add(heading);

                    var urls = new UnorderedList(HTMLElementType.HTML5);
                    foreach (var url in fb2File.DocumentInfo.SourceURLs)
                    {
                        var li = new ListItem(HTMLElementType.HTML5);
                        if (ReferencesUtils.IsExternalLink(url))
                        {
                            var link = new Anchor(HTMLElementType.HTML5);
                            link.HRef.Value = url;
                            link.Add(new SimpleHTML5Text(HTMLElementType.HTML5)
                            {
                                Text = url
                            });
                            li.Add(link);
                        }
                        else
                        {
                            li.Add(new SimpleHTML5Text(HTMLElementType.HTML5)
                            {
                                Text = url
                            });
                        }
                        urls.Add(li);
                    }
                    info.Add(urls);
                }

                if (fb2File.DocumentInfo.History != null)
                {
                    var heading = new H4(HTMLElementType.HTML5);
                    heading.Add(new SimpleHTML5Text(HTMLElementType.HTML5)
                    {
                        Text = "Document history:"
                    });
                    info.Add(heading);
                    var annotationConverter = new AnnotationConverterV3();
                    info.Add(annotationConverter.Convert(fb2File.DocumentInfo.History, new AnnotationConverterParamsV3 {
                        Level = 1, Settings = settings
                    }));
                    //Paragraph p = new Paragraph();
                    //p.Add(new SimpleHTML5Text() { Text = fb2File.DocumentInfo.History.ToString() });
                    //info.Add(p);
                }
            }

            // in case there is no elements - no need for a header
            if (info.SubElements().Count <= 1)
            {
                info.Remove(header);
            }

            SetClassType(info, ElementStylesV3.FB2Info);
            return(info);
        }