Exemple #1
0
        private string GetGenres(IEnumerable enu)
        {
            StringBuilder sb = new StringBuilder();

            foreach (FictionBookDescriptionTitleinfoGenre genre in enu)
            {
                string sGenre = GenreMap.GetRazaGenre(genre.Value).ToString();
                if (!String.IsNullOrEmpty(sGenre))
                {
                    sb.Append(sGenre + "; ");
                }
            }
            return(sb.ToString().TrimEnd(new char[] { ';', ' ' }));
        }
Exemple #2
0
        public ShareazaBook(FictionBook fb)
        {
            Trace.Assert(fb != null);

            if (fb.description == null)
            {
                return;
            }

            CultureInfo ciDefault = Thread.CurrentThread.CurrentCulture;
            CultureInfo ciDoc     = ciDefault;

            if (fb.description.titleinfo == null)
            {
                if (fb.description.custominfo != null)
                {
                    // Title in english ???
                    // custominfo and titleinfo should have a common interface then...
                    // this.title = fb.description.custominfo...
                }
            }
            else
            {
                this.title  = fb.description.titleinfo.booktitle.Value;
                this.author = GetAuthors(fb.description.titleinfo.author);
                try {
                    string sLang = fb.description.titleinfo.lang;
                    if (!String.IsNullOrEmpty(sLang))
                    {
                        // returns neutral culture!!! Beware when formatting
                        ciDoc         = CultureInfo.GetCultureInfoByIetfLanguageTag(sLang);
                        this.language = ciDoc.EnglishName;
                        // guess it
                        ciDoc = CultureInfo.CreateSpecificCulture(sLang + "-" + sLang);
                    }
                } catch { }

                if (fb.description.titleinfo.genre != null && fb.description.titleinfo.genre.Length > 0)
                {
                    this._genre = GenreMap.GetRazaGenre(fb.description.titleinfo.genre[0].Value);
                }
                // this.year = fb.description.titleinfo.date.value.Year;
                if (fb.description.titleinfo.keywords != null)
                {
                    this.keywords = fb.description.titleinfo.keywords.Value;
                }

                this.description = GetDescription(fb.description.titleinfo.annotation);
            }

            if (fb.description.publishinfo != null)
            {
                this.publisher = fb.description.publishinfo.publisher.Value;
                this.year      = fb.description.publishinfo.year;

                if (fb.description.publishinfo.isbn != null)
                {
                    string sISBN = fb.description.publishinfo.isbn.Value;
                    if (!String.IsNullOrEmpty(sISBN))
                    {
                        Int64 isbn;
                        if (Int64.TryParse(sISBN, out isbn))
                        {
                            this.ISBN = isbn;
                        }
                        else
                        {
                            sISBN = sISBN.Replace(@"-", String.Empty);
                            if (Int64.TryParse(sISBN, out isbn))
                            {
                                this.ISBN = isbn;
                            }
                        }
                    }
                }
            }

            if (fb.description.documentinfo != null)
            {
                this.distributer = GetAuthors(fb.description.documentinfo.author);
                this.releaseDate = GetDate(ciDoc, fb.description.documentinfo.date);
                this.edition     = fb.description.documentinfo.version.ToString();
            }

            this.back   = BackType.Digital;
            this.format = FormatType.FictionBook;
        }