I have a DumpContainer
to which I'd like to add content dynamically. I know I can set the Content
property to a new object but that gets rid of the previous content.
How can I add instead of replace?
Thanks for your help.
I have a DumpContainer
to which I'd like to add content dynamically. I know I can set the Content
property to a new object but that gets rid of the previous content.
How can I add instead of replace?
Thanks for your help.
A couple more options:
If you want the items displayed vertically, but not in a table, use Util.VerticalRun
inside a DumpContainer
:
var content = new List<object>();
var dc = new DumpContainer (Util.VerticalRun (content)).Dump();
content.Add ("some text");
dc.Refresh();
content.Add (new Uri ("http://www.linqpad.net"));
dc.Refresh();
If the items are generated asynchronously, use an asynchronous stream (C# 8):
async Task Main()
{
// LINQPad dumps IAsyncEnumerables in the same way as IObservables:
RangeAsync (0, 10).Dump();
}
public static async IAsyncEnumerable<int> RangeAsync (int start, int count)
{
for (int i = start; i < start + count; i++)
{
await Task.Delay (100);
yield return i;
}
}
Util
methods could be documented somewhere? :) –
Lockjaw If you are putting general objects in the DumpContainer
that are displayed with field values, etc. you could convert to a similar (but without the Display in Grid button) format with Util.ToHtmlString
and then concatenate.
var dc = new DumpContainer();
dc.Dump();
dc.Content = Util.RawHtml(Util.ToHtmlString(true, aVariable));
// some time later...
dc.Content = Util.RawHtml(Util.ToHtmlString(dc.Content)+Util.ToHtmlString(true, anotherVar));
Instead of adding content to the DumpContainer, go ahead and update it, but make its contents be something that has all the data you're trying to add.
var c = new DumpContainer();
var list = new List<string> {"message 1"};
c.Content = list;
c.Dump();
list.Add("message 2");
c.UpdateContent(list);
Alternatively, you can dump an IObservable<>
, and it'll automatically get updated as objects are emitted. (Import the System.Reactive NuGet package to make this work.)
var s = new Subject<string>();
s.Dump();
s.OnNext("message 1");
s.OnNext("message 2");
© 2022 - 2024 — McMap. All rights reserved.
Content
? (e.g.dc.Content += "\n new line of content";
). – Lockjaw