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; } }
protected override async Task OnInitializedAsync() { if (!string.IsNullOrWhiteSpace(Class) && string.IsNullOrEmpty(Code)) { Code = await CodeSnippetService.GetCodeSnippet(Class); } }
public IndexModel(CodeSnippetService codeSnippetService) { this.codeSnippetService = codeSnippetService; }
public CodeSnippetController(CodeSnippetService codeSnippetService) { this.codeSnippetService = codeSnippetService; }