Esempio n. 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;
            }
        }
Esempio n. 2
0
 public void Dispose()
 {
     DocExamples.RemoveCodeSnippet(this);
 }