public bool Convert(string sourceFileName, string targetFileName) { string input; var inputRetriever = InputRetriever.ForFileName(sourceFileName); try { input = inputRetriever.GetData(sourceFileName); } catch (FileNotFoundException) { return(false); } var doc = inputParser.Parse(input); var serializedDoc = documentSerializer.Serialize(doc); try { var documentPersister = DocumentPersister.ForFileName(targetFileName); documentPersister.Persist(serializedDoc, targetFileName); } catch (AccessViolationException) { return(false); } return(true); }
private static void ConfigureStorage() { var blobStorage = new BlobDocumentStorage(); var fileStorage = new FileDocumentStorage(); var httpInputRetriever = new HttpInputRetriever(); InputRetriever.RegisterInputRetriever(x => x.StartsWith("http", StringComparison.Ordinal), httpInputRetriever); InputRetriever.RegisterInputRetriever(IsBlobStorageUrl, blobStorage); InputRetriever.RegisterInputRetriever(x => true, fileStorage); DocumentPersister.RegisterDocumentPersister(IsBlobStorageUrl, blobStorage); DocumentPersister.RegisterDocumentPersister(x => true, fileStorage); }