当前位置: 首页>>代码示例>>C#>>正文


C# Markdown.MarkdownPage类代码示例

本文整理汇总了C#中ServiceStack.Support.Markdown.MarkdownPage的典型用法代码示例。如果您正苦于以下问题:C# MarkdownPage类的具体用法?C# MarkdownPage怎么用?C# MarkdownPage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MarkdownPage类属于ServiceStack.Support.Markdown命名空间,在下文中一共展示了MarkdownPage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        public void Init(MarkdownPage markdownPage, Dictionary<string, object> scopeArgs,
            bool renderHtml, ViewDataDictionary viewData, HtmlHelper htmlHelper)
		{
            Init(null, null, markdownPage.Markdown, viewData, htmlHelper);

            this.RenderHtml = renderHtml;
			this.MarkdownPage = markdownPage;
			this.ScopeArgs = scopeArgs;
		}
开发者ID:ELHANAFI,项目名称:ServiceStack,代码行数:9,代码来源:HtmlHelper.cs

示例2: Does_handle_foreach_when_enumerable_is_empty_first_time

        public void Does_handle_foreach_when_enumerable_is_empty_first_time()
        {
            var content = (string)dynamicListPageContent.Clone();
            var markdownPage = new MarkdownPage(new MarkdownFormat(), dynamicListPagePath, "", content);
            markdownPage.Compile();
            var model = new Person { Links = new List<Link>() };
            var scopeArgs = new Dictionary<string, object> { { "Model", model } };
            markdownPage.RenderToHtml(scopeArgs);             // First time the list is empty

            var expected = "A new list item";
            model.Links.Add(new Link { Name = expected } );
            var html = markdownPage.RenderToHtml(scopeArgs);  // Second time the list has 1 item

            Console.WriteLine(html);
            Assert.That(html, Contains.Substring(expected));
        }
开发者ID:ELHANAFI,项目名称:ServiceStack,代码行数:16,代码来源:TextBlockTests.cs

示例3: RenderDynamicPage

        public string RenderDynamicPage(MarkdownPage markdownPage, Dictionary<string, object> scopeArgs,
            bool renderHtml, bool renderTemplate, string templatePath = null)
        {
            scopeArgs = scopeArgs ?? new Dictionary<string, object>();
            var htmlPage = markdownPage.RenderToString(scopeArgs, renderHtml);
            if (!renderTemplate) return htmlPage;

            var html = RenderInTemplateIfAny(
                markdownPage, scopeArgs, htmlPage, templatePath);

            return html;
        }
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:12,代码来源:MarkdownFormat.cs

示例4: RenderInTemplateIfAny

        private string RenderInTemplateIfAny(MarkdownPage markdownPage, Dictionary<string, object> scopeArgs, string pageHtml, string templatePath = null)
        {
            MarkdownTemplate markdownTemplate = null;

            if (templatePath != null)
                MasterPageTemplates.TryGetValue(templatePath, out markdownTemplate);

            var directiveTemplate = markdownPage.DirectiveTemplate;
            if (markdownTemplate == null && directiveTemplate != null)
            {
                if (!MasterPageTemplates.TryGetValue(directiveTemplate, out markdownTemplate))
                {
                    var templateInSharedPath = "{0}/{1}.shtml".Fmt(SharedDir, directiveTemplate);
                    if (!MasterPageTemplates.TryGetValue(templateInSharedPath, out markdownTemplate))
                    {
                        var virtualFile = VirtualPathProvider.GetFile(directiveTemplate);
                        if (virtualFile == null)
                            throw new FileNotFoundException("Could not find template: " + directiveTemplate);

                        var templateContents = GetPageContents(virtualFile);
                        markdownTemplate = AddTemplate(directiveTemplate, templateContents);
                    }
                }
            }

            if (markdownTemplate == null)
            {
                if (markdownPage.Template != null)
                    MasterPageTemplates.TryGetValue(markdownPage.Template, out markdownTemplate);

                if (markdownTemplate == null && templatePath == null)
                    MasterPageTemplates.TryGetValue(DefaultTemplate, out markdownTemplate);

                if (markdownTemplate == null)
                {
                    if (templatePath == null)
                        return pageHtml;

                    throw new Exception("No template found for page: " + markdownPage.FilePath);
                }
            }

            if (scopeArgs != null)
                scopeArgs[MarkdownTemplate.BodyPlaceHolder] = pageHtml;

            var htmlPage = markdownTemplate.RenderToString(scopeArgs);

            return htmlPage;
        }
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:49,代码来源:MarkdownFormat.cs

示例5: RenderStaticPage

 private string RenderStaticPage(MarkdownPage markdownPage, bool renderHtml)
 {
     //TODO: Optimize if contains no dynamic elements
     return RenderDynamicPage(markdownPage, new Dictionary<string, object>(), renderHtml, true);
 }
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:5,代码来源:MarkdownFormat.cs

示例6: AddViewPage

 private void AddViewPage(MarkdownPage page)
 {
     switch (page.PageType)
     {
         case MarkdownPageType.ViewPage:
             ViewPages.Add(page.Name, page);
             break;
         case MarkdownPageType.SharedViewPage:
             ViewSharedPages.Add(page.Name, page);
             break;
         case MarkdownPageType.ContentPage:
             ContentPages.Add(page.FilePath.WithoutExtension().TrimStart(DirSeps), page);
             break;
     }
 }
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:15,代码来源:MarkdownFormat.cs

示例7: AddPage

        public void AddPage(MarkdownPage page)
        {
            try
            {
				page.Compile();
                AddViewPage(page);
            }
            catch (Exception ex)
            {
                Log.Error("AddViewPage() page.Prepare(): " + ex.Message, ex);
            }

            try
            {
                var templatePath = page.Template;
                if (page.Template == null) return;

                if (MasterPageTemplates.ContainsKey(templatePath)) return;

                var templateFile = VirtualPathProvider.GetFile(templatePath);
                var templateContents = GetPageContents(templateFile);
                AddTemplate(templatePath, templateContents);
            }
            catch (Exception ex)
            {
                Log.Error("Error compiling template " + page.Template + ": " + ex.Message, ex);
            }
        }
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:28,代码来源:MarkdownFormat.cs

示例8: RegisterMarkdownPage

		public void RegisterMarkdownPage(MarkdownPage markdownPage)
        {
            AddPage(markdownPage);
        }
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:4,代码来源:MarkdownFormat.cs

示例9: GetLatestPage

 private IVirtualFile GetLatestPage(MarkdownPage markdownPage)
 {
     var file = VirtualPathProvider.GetFile(markdownPage.FilePath);
     return file;
 }
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:5,代码来源:MarkdownFormat.cs

示例10: ReloadIfNeeded

 private MarkdownPage ReloadIfNeeded(MarkdownPage markdownPage)
 {
     if (markdownPage == null || !WatchForModifiedPages) return markdownPage;
     if (markdownPage.FilePath != null)
     {
         var latestPage = GetLatestPage(markdownPage);
         if (latestPage == null) return markdownPage;
         if (latestPage.LastModified > markdownPage.LastModified)
         {
             markdownPage.Reload(GetPageContents(latestPage), latestPage.LastModified);
         }
     }
     return markdownPage;
 }
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:14,代码来源:MarkdownFormat.cs

示例11: ReloadModifiedPageAndTemplates

        public void ReloadModifiedPageAndTemplates(MarkdownPage markdownPage)
        {
            if (markdownPage == null || !WatchForModifiedPages) return;

            ReloadIfNeeded(markdownPage);

            IVirtualFile latestPage;
            MarkdownTemplate template;
            if (markdownPage.DirectiveTemplate != null
                && this.MasterPageTemplates.TryGetValue(markdownPage.DirectiveTemplate, out template))
            {
                latestPage = GetLatestPage(markdownPage.DirectiveTemplate);
                if (latestPage.LastModified > template.LastModified)
                    template.Reload(GetPageContents(latestPage), latestPage.LastModified);
            }
            if (markdownPage.Template != null
                && this.MasterPageTemplates.TryGetValue(markdownPage.Template, out template))
            {
                latestPage = GetLatestPage(template);
                if (latestPage.LastModified > template.LastModified)
                    template.Reload(GetPageContents(latestPage), latestPage.LastModified);
            }
        }
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:23,代码来源:MarkdownFormat.cs

示例12: ProcessMarkdownPage

        public bool ProcessMarkdownPage(IRequest httpReq, MarkdownPage markdownPage, object dto, IResponse httpRes)
        {
            httpRes.AddHeaderLastModified(markdownPage.GetLastModified());

            var renderInTemplate = true;
            var renderHtml = true;
            string format;
            if (httpReq != null && (format = httpReq.QueryString["format"]) != null)
            {
                renderHtml = !(format.StartsWithIgnoreCase("markdown")
                    || format.StartsWithIgnoreCase("text")
                    || format.StartsWithIgnoreCase("plain"));
                renderInTemplate = !httpReq.GetFormatModifier().StartsWithIgnoreCase("bare");
            }

            if (!renderHtml)
            {
                httpRes.ContentType = MimeTypes.PlainText;
            }

            var template = httpReq.GetTemplate();
            var markup = RenderDynamicPage(markdownPage, markdownPage.Name, dto, renderHtml, renderInTemplate, template);
            var markupBytes = markup.ToUtf8Bytes();
            httpRes.OutputStream.Write(markupBytes, 0, markupBytes.Length);

            return true;
        }
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:27,代码来源:MarkdownFormat.cs

示例13: AddFileAndPage

 public static void AddFileAndPage(this MarkdownFormat markdown, MarkdownPage markdownPage)
 {
     var pathProvider = (InMemoryVirtualPathProvider)markdown.VirtualPathProvider;
     pathProvider.WriteFile(markdownPage.FilePath, markdownPage.Contents);
     markdown.AddPage(markdownPage);
 }
开发者ID:CLupica,项目名称:ServiceStack,代码行数:6,代码来源:MarkdownFormatExtensions.cs

示例14: AddViewPage

 private void AddViewPage(MarkdownPage page)
 {
     switch (page.PageType)
     {
         case MarkdownPageType.ViewPage:
             ViewPages.Add(page.Name, page);
             break;
         case MarkdownPageType.SharedViewPage:
             ViewSharedPages.Add(page.Name, page);
             break;
         case MarkdownPageType.ContentPage:
             ContentPages.Add(SanitizePath(page.FilePath), page);
             break;
     }
 }
开发者ID:jin29neci,项目名称:ServiceStack,代码行数:15,代码来源:MarkdownFormat.cs

示例15: Does_transform_escaped_html_start_tags

		public void Does_transform_escaped_html_start_tags()
		{
			var markdownText =
			@"#### Showing Results 1 - 5

^<div id=""searchresults"">

### Markdown &gt; [About Docs](http://path.com/to/about)

^</div>

Text".NormalizeNewLines();

			var expectedHtml =
			@"<h4>Showing Results 1 - 5</h4>
<div id=""searchresults"">
<h3>Markdown &gt; <a href=""http://path.com/to/about"">About Docs</a></h3>
</div>
<p>Text</p>
".NormalizeNewLines();

			var textBlock = new TextBlock("");
			var page = new MarkdownPage { Markdown = new MarkdownFormat() };
			textBlock.DoFirstRun(new PageContext(page, null, true));

			var html = textBlock.TransformHtml(markdownText);

			Console.WriteLine(html);

			Assert.That(html, Is.EqualTo(expectedHtml));
		}
开发者ID:ELHANAFI,项目名称:ServiceStack,代码行数:31,代码来源:TextBlockTests.cs


注:本文中的ServiceStack.Support.Markdown.MarkdownPage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。