Example #1
0
        public void Convert(FileExtension inputExtension, Stream inputStream, FileExtension outputExtension, Stream outputStream)
        {
            IDocumentReader reader = ReaderCatalog.FirstOrDefault(x => x.FileExtension == inputExtension);

            if (reader == null)
            {
                return;
            }

            IDocumentWriter writer = WriterCatalog.FirstOrDefault(x => x.FileExtension == outputExtension);

            writer?.Convert(reader.Convert(inputStream), outputStream);
        }
Example #2
0
        public void Convert(FileExtension inputExtension, Stream inputStream, Dictionary <FileExtension, Stream> outputStreams)
        {
            IDocumentReader reader = ReaderCatalog.FirstOrDefault(x => x.FileExtension == inputExtension);

            if (reader == null)
            {
                return;
            }

            foreach ((IDocumentWriter writer, Stream stream)item in outputStreams.Select(e => (WriterCatalog.FirstOrDefault(x => x.FileExtension == e.Key), e.Value)))
            {
                item.writer?.Convert(reader.Convert(inputStream), item.stream);
            }
        }
Example #3
0
        public FileExtension Convert(string inputExtension, Stream inputStream, string outputExtension, Stream outputStream)
        {
            IDocumentReader reader = ReaderCatalog.BestMatch(inputExtension);

            if (reader == null)
            {
                return(default(FileExtension));
            }

            IDocumentWriter writer = WriterCatalog.BestMatch(outputExtension);

            if (writer == null)
            {
                return(default(FileExtension));
            }

            writer.Convert(reader.Convert(inputStream), outputStream);
            return(writer.FileExtension);
        }