public bool ConvertFormat(string sourceFileName, string targetFileName) { string input; try { var inputRetriever = InputRetriever.ForFileName(sourceFileName); input = inputRetriever.GetData(sourceFileName); } catch (FileNotFoundException) { return(false); } var doc = _inputParser.ParseInput(input); var serializedDoc = _documentSerializer.Serialize(doc); try { var documentPersister = DocumentPersister.ForFileName(targetFileName); documentPersister.PersistDocument(serializedDoc, targetFileName); } catch (AccessViolationException) { return(false); } return(true); }
private static void ConfigureStorage() { var blobStorage = new BlobDocumentStorage(ConfigurationManager.AppSettings["storageAccount"], ConfigurationManager.AppSettings["storageKey"]); var fileStorage = new FileDocumentStorage(); var httpInputRetriever = new HttpInputRetriever(); InputRetriever.RegisterInputRetriever(x => x.StartsWith("http"), httpInputRetriever); InputRetriever.RegisterInputRetriever(IsBlobstorageUrl, blobStorage); InputRetriever.RegisterInputRetriever(x => true, fileStorage); DocumentPersister.RegisterDocumentPersister(IsBlobstorageUrl, blobStorage); DocumentPersister.RegisterDocumentPersister(x => true, fileStorage); }