LinqPad Dump from DLL

2019-07-27 11:38发布

I would like to be able to call Dump from my DLL and code below returns raw HTML result. How can I render it, or what is the correct approach?

Method

public static string Dump<T>(this T obj)
{
    var writer = LINQPad.Util.CreateXhtmlWriter();
    writer.Write(obj);
    return writer.ToString();
}

Call

Debug.WriteLine(myObject.Dump());

Result on LINQPad

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
      <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
      <meta name="Generator" content="LINQ to XML, baby!" />
      <style type='text/css'>
        ...
      </style>
  </head>
<body>
<div>
...
</div>
</body>
</html>

标签: c# xhtml linqpad
1条回答
相关推荐>>
2楼-- · 2019-07-27 12:08

Thanks to Joe Albahari, adding LinqPad.exe as reference allows us to use Dump function from the library so no implementation is needed.

查看更多
登录 后发表回答