定義
staticclassDumpExtensions
{
publicstaticvoid DumpExH1(thisstringvalue)
=> DumpWrappedWithTags(value, "h1");
publicstaticvoid DumpExH2(thisstringvalue)
=> DumpWrappedWithTags(value, "h2");
publicstaticvoid DumpExH3(thisstringvalue)
=> DumpWrappedWithTags(value, "h3");
privatestaticvoid DumpWrappedWithTags(stringvalue, string tag)
{
Util.RawHtml($"<{tag}>{value}</{tag}>").Dump();
}
publicstaticvoid DumpExColor(thisstringvalue, ConsoleColor color = ConsoleColor.Black, ConsoleColor? background =null)
{
var colorStr =$"color: {color}; ";
var backgroundStr = background !=null?$"background-color: {background}; ":"";
Util.WithStyle(value, $"{colorStr}{backgroundStr} display: block; ").Dump();
}
}
利用
void Main()
{
"Header1".DumpExH1();
"Header2".DumpExH2();
"Header3".DumpExH3();
"default".DumpExColor();
"red".DumpExColor(ConsoleColor.Red);
"cyan".DumpExColor(background: ConsoleColor.Cyan);
"blue and yellow".DumpExColor(ConsoleColor.Blue, ConsoleColor.Yellow);
}
![]()