blob: ca11cc4aa2384a625a561d98dbd57976bd27d291 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace Google.GRPC.Core.Utils
{
public class RecordingObserver<T> : IObserver<T>
{
TaskCompletionSource<List<T>> tcs = new TaskCompletionSource<List<T>>();
List<T> data = new List<T>();
public void OnCompleted()
{
tcs.SetResult(data);
}
public void OnError(Exception error)
{
tcs.SetException(error);
}
public void OnNext(T value)
{
data.Add(value);
}
public Task<List<T>> ToList() {
return tcs.Task;
}
}
}
|