當前位置: 首頁>>代碼示例>>C#>>正文


C# Markdown.MarkdownPage類代碼示例

本文整理匯總了C#中ServiceStack.WebHost.Endpoints.Support.Markdown.MarkdownPage的典型用法代碼示例。如果您正苦於以下問題:C# MarkdownPage類的具體用法?C# MarkdownPage怎麽用?C# MarkdownPage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MarkdownPage類屬於ServiceStack.WebHost.Endpoints.Support.Markdown命名空間,在下文中一共展示了MarkdownPage類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

        public static void Main(string[] args)
        {
            // Get executing path and /example.md full path
            string exeLocation = Assembly.GetExecutingAssembly().Location;
            string path = Path.GetDirectoryName( exeLocation );
            string template = Path.Combine(path, "example.md");

            // Create the markdown-razor template compiler
            MarkdownFormat format = new MarkdownFormat();
            string contents = File.ReadAllText(template);
            var page = new MarkdownPage(format, path, "example", contents );
            format.AddPage(page);

            // Create our view container (ViewBag)
            var view = new Dictionary<string, object>()
            {
                { "examples", examples }
            };

            // Compile and output.
            // This can be redirected to html file
            // e.g. RazorExample.exe > output.html
            var html = format.RenderDynamicPageHtml("example", view);
            Console.WriteLine(html);
        }
開發者ID:tjmukurumbira,項目名稱:blogs,代碼行數:25,代碼來源:Main.cs

示例2: 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:HansS,項目名稱:ServiceStack,代碼行數:9,代碼來源:HtmlHelper.cs

示例3: 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:KennyBu,項目名稱:ServiceStack,代碼行數:16,代碼來源:TextBlockTests.cs

示例4: RegisterMarkdownPage

 public void RegisterMarkdownPage(MarkdownPage markdownPage)
 {
     AddPage(markdownPage);
 }
開發者ID:Arxisos,項目名稱:ServiceStack,代碼行數:4,代碼來源:MarkdownFormat.cs

示例5: ProcessMarkdownPage

        public bool ProcessMarkdownPage(IHttpRequest httpReq, MarkdownPage markdownPage, object dto, IHttpResponse 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 = ContentType.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:Arxisos,項目名稱:ServiceStack,代碼行數:27,代碼來源:MarkdownFormat.cs

示例6: AddPage

        public void AddPage(MarkdownPage page)
        {
            try
            {
                page.Prepare();
                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(), page);
                        break;
                }
            }
            catch (Exception ex)
            {
                Log.Error("AddViewPage() page.Prepare(): " + ex.Message, ex);
            }

            var templatePath = page.TemplatePath;
            if (page.TemplatePath == null) return;

            if (PageTemplates.ContainsKey(templatePath)) return;

            AddTemplate(templatePath, File.ReadAllText(templatePath));
        }
開發者ID:Arxisos,項目名稱:ServiceStack,代碼行數:30,代碼來源:MarkdownFormat.cs

示例7: AddFileAndPage

 public static void AddFileAndPage(this MarkdownFormat markdown, MarkdownPage markdownPage)
 {
     var pathProvider = (InMemoryVirtualPathProvider)markdown.VirtualPathProvider;
     pathProvider.AddFile(markdownPage.FilePath, markdownPage.Contents);
     markdown.AddPage(markdownPage);
 }
開發者ID:grammarware,項目名稱:fodder,代碼行數:6,代碼來源:tests_ServiceStack_ServiceHost_Tests_Formats_MarkdownFormatExtensions.cs

示例8: 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:Arxisos,項目名稱:ServiceStack,代碼行數:5,代碼來源:MarkdownFormat.cs

示例9: RenderDynamicPage

        private string RenderDynamicPage(MarkdownPage markdownPage, string pageName, object model, bool renderHtml, bool renderTemplate, string templatePath = null)
        {
            if (markdownPage == null)
                throw new InvalidDataException(ErrorPageNotFound.FormatWith(pageName));

            var scopeArgs = new Dictionary<string, object> { { MarkdownPage.ModelName, model } };

            return RenderDynamicPage(markdownPage, scopeArgs, renderHtml, renderTemplate, templatePath);
        }
開發者ID:Arxisos,項目名稱:ServiceStack,代碼行數:9,代碼來源:MarkdownFormat.cs

示例10: 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:JonCanning,項目名稱:ServiceStack,代碼行數:28,代碼來源:MarkdownFormat.cs

示例11: GetLatestPage

 private IVirtualFile GetLatestPage(MarkdownPage markdownPage)
 {
     var file = VirtualPathProvider.GetFile(markdownPage.FilePath);
     return file;
 }
開發者ID:JonCanning,項目名稱:ServiceStack,代碼行數:5,代碼來源:MarkdownFormat.cs

示例12: 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:JonCanning,項目名稱:ServiceStack,代碼行數:14,代碼來源:MarkdownFormat.cs

示例13: 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:JonCanning,項目名稱:ServiceStack,代碼行數:23,代碼來源:MarkdownFormat.cs

示例14: ReloadModifiedPageAndTemplates

        public void ReloadModifiedPageAndTemplates(MarkdownPage markdownPage)
        {
            var lastWriteTime = File.GetLastWriteTime(markdownPage.FilePath);
            if (lastWriteTime > markdownPage.LastModified)
            {
                markdownPage.Reload();
            }

            MarkdownTemplate template;
            if (markdownPage.DirectiveTemplatePath != null
                && this.PageTemplates.TryGetValue(markdownPage.DirectiveTemplatePath, out template))
            {
                lastWriteTime = File.GetLastWriteTime(markdownPage.DirectiveTemplatePath);
                if (lastWriteTime > template.LastModified)
                    ReloadTemplate(template);
            }
            if (markdownPage.TemplatePath != null
                && this.PageTemplates.TryGetValue(markdownPage.TemplatePath, out template))
            {
                lastWriteTime = File.GetLastWriteTime(markdownPage.TemplatePath);
                if (lastWriteTime > template.LastModified)
                    ReloadTemplate(template);
            }
        }
開發者ID:Arxisos,項目名稱:ServiceStack,代碼行數:24,代碼來源:MarkdownFormat.cs

示例15: 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:JonCanning,項目名稱:ServiceStack,代碼行數:15,代碼來源:MarkdownFormat.cs


注:本文中的ServiceStack.WebHost.Endpoints.Support.Markdown.MarkdownPage類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。