當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。