Example #1
0
 public ContentReader(Book book, ContentReaderParameters parameters, Log log)
 {
     string identifier = null;
     if (parameters.Index > 0)
         identifier = parameters.Index.ToString(CultureInfo.InvariantCulture);
     else if (!string.IsNullOrEmpty(parameters.File))
         identifier = parameters.File;
     else if (!string.IsNullOrEmpty(parameters.Format))
         identifier = parameters.Format;
     var volume = book.GetVolume(identifier);
     var files = new FileSource { Log = log };
     Encoding encoding;
     Content = files.Open(volume, out encoding);
     if (parameters.WasStreamTypeSpecified)
         encoding = parameters.GetEncoding();
     try {
         if (!parameters.UsingByteEncoding)
             Reader = new StreamReader(Content, encoding);
     } catch {
         Content.Close();
         throw;
     }
 }