Exemplo n.º 1
0
        public async Task <IMarkpadDocument> OpenDocument(string path)
        {
            var contents = await fileSystem.File.ReadAllTextAsync(path);

            var siteContext = siteContextGenerator.GetContext(path);

            var associatedImages = GetAssociatedImages(contents, siteContext);

            return(new FileMarkdownDocument(path, contents, siteContext, associatedImages, this, eventAggregator, dialogService, fileSystem));
        }
Exemplo n.º 2
0
        public Task <IMarkpadDocument> NewMarkdownFile(string path, string markdownContent)
        {
            //TODO async all the things
            var streamWriter = new StreamWriter(path);

            return(streamWriter
                   .WriteAsync(markdownContent)
                   .ContinueWith <IMarkpadDocument>(t =>
            {
                streamWriter.Dispose();

                t.PropagateExceptions();

                var siteContext = siteContextGenerator.GetContext(path);

                return new FileMarkdownDocument(path, markdownContent, siteContext, this, eventAggregator, dialogService);
            }));
        }
Exemplo n.º 3
0
        public async Task OpenDocument_RestoresAssociatedFiles()
        {
            // arrange
            const string toOpen  = @"c:\Path\File.md";
            const string content = @"Some text

![Alt](File_images\File1.png)";

            fileSystem.File.Exists(@"c:\Path\File_images\File1.png").Returns(true);
            fileSystem.File.ReadAllTextAsync(toOpen).Returns(TaskEx.FromResult(content));
            siteContextGenerator.GetContext(toOpen).Returns(new SingleFileContext(toOpen));

            // act
            var document = await documentFactory.OpenDocument(toOpen);

            // assert
            Assert.Equal(1, document.AssociatedFiles.Count());
        }
Exemplo n.º 4
0
 private void EvaluateContext()
 {
     SiteContext = siteContextGenerator.GetContext(FileName);
 }