public void Convert(ItemTitleInfo itemTitleInfo, IBookInformationData titleInformation)
        {
            titleInformation.Languages.Clear();
            titleInformation.Creators.Clear();
            titleInformation.Contributors.Clear();
            titleInformation.Subjects.Clear();
            titleInformation.Identifiers.Clear();


            // in case main body title is not defined (empty)
            if ((itemTitleInfo != null) && (itemTitleInfo.BookTitle != null))
            {
                titleInformation.BookMainTitle = itemTitleInfo.BookTitle.Text;
            }

            titleInformation.AllSequences.Clear();

            if (itemTitleInfo != null)
            {
                // Pass all sequences
                SequencesInfoConverterV3.Convert(itemTitleInfo, titleInformation);

                // Getting information from FB2 Title section
                ConvertMainTitle(itemTitleInfo, titleInformation);

                // add authors
                AuthorsInfoConverterV3.Convert(itemTitleInfo, _conversionSettings, titleInformation);

                // add translators
                TranslatorsInfoConverterV3.Convert(itemTitleInfo, titleInformation, _conversionSettings);

                // genres
                GenresInfoConverterV3.Convert(itemTitleInfo, titleInformation, _conversionSettings);
            }
            titleInformation.DateFileCreation = DateTime.Now;
        }
Exemple #2
0
        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(
                            string.Format("{0} {1} {2}", author.FirstName, author.MiddleName, author.LastName),
                            _conversionSettings.TransliterationSettings),
                    FileAs   = DescriptionConverters.GenerateFileAsString(author, _conversionSettings),
                    Role     = RolesEnum.Author,
                    Language = fb2File.SourceTitleInfo.Language
                };
                titleInformation.Creators.Add(person);
            }

            TranslatorsInfoConverterV3.Convert(fb2File.SourceTitleInfo, titleInformation, _conversionSettings);
            GenresInfoConverterV3.Convert(fb2File.SourceTitleInfo, titleInformation, _conversionSettings);
        }