Ejemplo n.º 1
0
        protected override async Task OnInitializedAsync()
        {
            DocsExample.AddCodeSnippet(this);

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

                var html = await CodeSnippetService.GetCodeSnippet(ClassName);

                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 += "<div class='mt-1'>" + formatter.GetHtmlString(cSharp, Languages.CSharp) + "</div>";
                }


                code = HighlightRazor(code);

                Code = code;
            }
        }
Ejemplo n.º 2
0
 public void Dispose()
 {
     DocsExample.RemoveCodeSnippet(this);
 }