ToDump - Determine Output is Grid or HTML (Output Tab)?
Options
Is there currently a built-in way to determine if the ToDump results will be directed to the HTML Output tab or to a grid? For example, I want to display the data a certain way when dumped to the Output tab but display it a different way (no controls or DumpContainer instances) when displayed in a Grid.
Gratis!
Comments
-
No additional parameter is passed to
ToDump
, so I can't see any easy way. -
If performance is not an issue and you are happy to depend on internal method names , then you could use a trick similar to the one mentioned in https://forum.linqpad.net/discussion/comment/7677#Comment_7677
e.g.
public class Test { public string? Name = "xxx"; public decimal? Value = 100; public LINQPad.Controls.Button btn = new LINQPad.Controls.Button("Test"); object ToDump() { var toGrid = new StackTrace().ToString().Contains("at LINQPad.UI.RuntimeUIServices.DisplayInGrid("); return toGrid ? new { Name, Value} : this; } }