Пример #1
0
 public FinaliseContext(
     ScaffoldContext scaffoldContext,
     List <MarkupContext> markupContexts,
     Dictionary <string, HtmlContext> html
     )
 {
     ScaffoldContext = scaffoldContext;
     MarkupContexts  = markupContexts;
     HtmlContexts    = html;
 }
Пример #2
0
        public MarkupContext(ScaffoldContext scaffoldContext, string markdownPath, string markdownContent, string htmlUrl, string htmlContentTemplate)
        {
            Markdown = new MarkdownProperties();
            Html     = new HtmlProperties();
            Image    = new ImageProperties();

            ScaffoldContext = scaffoldContext;
            Title           = "";
            Slug            = "";
            Tags            = new List <TagItem>();
            PostedDate      = DateTime.MinValue;

            Markdown.Path        = markdownPath;
            Markdown.Content     = markdownContent;
            Html.Url.RelativeUrl = htmlUrl;
            Html.Path            = Path.ChangeExtension(markdownPath, ".html");
            Html.Content         = htmlContentTemplate;
        }
Пример #3
0
        public async Task <FinaliseContext> NewFinaliseContextAsync(
            ScaffoldContext scaffoldContext,
            List <MarkupContext> markupContexts
            )
        {
            var htmlContextsTask = Directory.GetFiles
                                   (
                scaffoldContext.SiteRoot,
                "*.html",
                new EnumerationOptions
            {
                RecurseSubdirectories = true
            }
                                   )
                                   .Select(path =>
            {
                Func <string, Task <HtmlContext> > GetHtmlContext = async(string path)
                                                                    => new HtmlContext
                {
                    Path    = path,
                    Url     = scaffoldContext.ConvertPathToUrl(path),
                    Content = await File.ReadAllTextAsync(path)
                };

                return(GetHtmlContext(path));
            }
                                           )
                                   .ToList()
            ;

            var htmlContexts = await Task.WhenAll(htmlContextsTask);

            var htmlContextsDict = htmlContexts.ToDictionary(c => c.Url);

            return(new FinaliseContext(scaffoldContext, markupContexts, htmlContextsDict));
        }
Пример #4
0
 public ContextFactory(Config config)
 {
     _config          = config;
     _scaffoldContext = new ScaffoldContextFactory().NewScaffoldContext(config);
 }