Reputation: 652
I've seen lots of answers on here and in various posts and tutorials on other sites where the Dump()
method is used on an IObservable<T>
sequence. However, when I try to use it, I get a ... does not contain a definition for 'Dump' and no extension method for 'Dump' ... Cannot resolve symbol 'Dump'
warning from the compiler. Has it been removed from Rx, or am I missing a library?
Upvotes: 2
Views: 867
Reputation: 9840
Recommend to use LINQPad related nuget package (LINQPad officially provided), then you can use Dump()
method of it.
Sample code:
using System;
using LINQPad;
namespace Csharp_Dump_Test
{
public class Program
{
public static void Main()
{
try
{
DoSomething();
}
catch (Exception ex)
{
ex.Dump();
}
}
private static void DoSomething()
{
throw new Exception("Unable.");
}
}
}
Upvotes: 2
Reputation: 2275
Yes I agree with the comments that it exists in LinqPad, however you may write your own as in http://www.introtorx.com/content/v1.0.10621.0/07_Aggregation.html
public static class SampleExtentions
{
public static void Dump<T>(this IObservable<T> source, string name)
{
source.Subscribe(
i=>Console.WriteLine("{0}-->{1}", name, i),
ex=>Console.WriteLine("{0} failed-->{1}", name, ex.Message),
()=>Console.WriteLine("{0} completed", name));
}
}
Upvotes: 3