예제 #1
0
파일: EnvyBook.cs 프로젝트: sahwar/Envy
		private string GetGenres(IEnumerable enu) {
			StringBuilder sb = new StringBuilder();
			foreach (FictionBookDescriptionTitleinfoGenre genre in enu) {
				string sGenre = GenreMap.GetEnvyGenre(genre.Value).ToString();
				if (!String.IsNullOrEmpty(sGenre))
					sb.Append(sGenre + "; ");
			}
			return sb.ToString().TrimEnd(new char[] { ';', ' ' });
		}
예제 #2
0
파일: EnvyBook.cs 프로젝트: sahwar/Envy
		public EnvyBook(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.GetEnvyGenre(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;
			}

			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;
		}