예제 #1
0
        protected override async Task OnInitializedAsync()
        {
            DocExamples.AddCodeSnippet(this);

            if (!string.IsNullOrWhiteSpace(ClassName) && string.IsNullOrEmpty(Code))
            {
                var formatter = new HtmlClassFormatter();

                var html   = (await CodeSnippetService.GetCodeSnippet(ClassName)).Trim();
                var cSharp = "";

                var index = html.IndexOf("@code {");
                if (index > 0)
                {
                    cSharp = html.Substring(index);
                    html   = html.Substring(0, index);
                }

                var code = formatter.GetHtmlString(html, Languages.Html);

                if (!string.IsNullOrWhiteSpace(cSharp))
                {
                    code = code + @" <div class=""mb-1""> </div> " + formatter.GetHtmlString(cSharp, Languages.CSharp);
                }


                code = HighlightRazor(code);

                Code = code;
            }
        }
예제 #2
0
 protected override async Task OnInitializedAsync()
 {
     if (!string.IsNullOrWhiteSpace(Class) && string.IsNullOrEmpty(Code))
     {
         Code = await CodeSnippetService.GetCodeSnippet(Class);
     }
 }
예제 #3
0
 public IndexModel(CodeSnippetService codeSnippetService)
 {
     this.codeSnippetService = codeSnippetService;
 }
예제 #4
0
 public CodeSnippetController(CodeSnippetService codeSnippetService)
 {
     this.codeSnippetService = codeSnippetService;
 }